npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@depoc/storefront-sdk

v1.2.0

Published

Official TypeScript/JavaScript SDK for Depoc shop storefronts — connect Next.js, Nuxt, Angular, Astro, and any JS frontend to api.depoc.ir

Readme

@depoc/storefront-sdk

Official TypeScript/JavaScript SDK for connecting shop storefronts to Depoc.

Works with Next.js, Nuxt, Angular, Astro, SvelteKit, Remix, and any environment with fetch (Node 18+, browsers, edge runtimes).

Install

npm install @depoc/storefront-sdk
# or
yarn add @depoc/storefront-sdk
# or
pnpm add @depoc/storefront-sdk

Quick start

  1. Create an API key in Depoc Panel → Shops → [your shop] → API Keys
  2. Configure your storefront:
import { DepocStorefront } from '@depoc/storefront-sdk'

const depoc = new DepocStorefront({
  apiKey: process.env.DEPOC_API_KEY!, // depoc_live_...
  // Optional overrides (defaults shown):
  // apiOrigin: 'https://api.depoc.ir',
  // siteUrl: 'https://depoc.ir',
})

// Shop branding & enabled modules
const shop = await depoc.getShopContext()
console.log(shop.siteName, shop.modules)

// Catalog
const homepage = await depoc.getHomepage()
const product = await depoc.getProduct('industrial-pump-x200')
const results = await depoc.searchProducts('پمپ', { sortBy: 'price-low' })

// Checkout (guest checkout — cart is client-side)
const quote = await depoc.getShippingQuote(
  depoc.cart.load().map((item) => ({
    productId: item.productId,
    quantity: item.quantity,
    unitPrice: item.unitPrice,
  }))
)

const order = await depoc.createOrder({
  firstName: 'علی',
  lastName: 'رضایی',
  email: '[email protected]',
  phone: '09123456789',
  address: {
    fullAddress: 'خیابان ولیعصر، پلاک ۱۰',
    city: 'تهران',
    province: 'تهران',
    postalCode: '1234567890',
  },
  paymentMethod: 'card',
  items: depoc.cart.load().map((item) => ({
    productId: item.productId,
    productName: item.productName,
    productImage: item.productImage,
    sku: item.sku,
    quantity: item.quantity,
    unitPrice: item.unitPrice,
  })),
})

// Online payment (Zarinpal, etc.)
const payment = await depoc.initiatePayment({
  orderId: order.id,
  amount: order.total,
  customerPhone: '09123456789',
})
window.location.href = payment.paymentUrl

// Or use the full Depoc-hosted flow (recommended):
await depoc.completeCardCheckout({ order, customerEmail: '[email protected]' })
// → redirects to Zarinpal → api.depoc.ir verifies → back to your shop /checkout/success

Depoc-hosted payments

Payments are processed on Depoc servers (api.depoc.ir). Your shop never talks to Zarinpal directly.

Shop frontend                api.depoc.ir                 Zarinpal
     │                            │                          │
     │  initiatePayment()         │                          │
     │ ─────────────────────────► │  request payment         │
     │ ◄───────────────────────── │ ────────────────────────► │
     │  paymentUrl                │                          │
     │ ─────────────────────────────────────────────────────► │
     │                            │ ◄──── callback ────────── │
     │                            │  verify + update order   │
     │ ◄── redirect to shop ───── │                          │
     │  /checkout/success         │                          │
  1. SDK calls POST /checkout/payments/initiate with your shop returnUrl
  2. Customer pays on Zarinpal
  3. Zarinpal redirects to https://api.depoc.ir/api/v1/checkout/payments/callback
  4. Depoc verifies payment, updates order status
  5. Customer is redirected to {siteUrl}/checkout/success?orderId=...&payment=paid
// One-liner after order creation
await depoc.completeCardCheckout({ order, customerEmail: user.email })

// Manual control
const payment = await depoc.initiatePayment({
  orderId: order.id,
  amount: order.total,
  returnUrl: 'https://myshop.com/order/success',
  failureUrl: 'https://myshop.com/order/failed',
})
depoc.redirectToPaymentGateway(payment)

// Poll or verify (SPA / mobile)
const status = await depoc.getPaymentStatus(payment.id)
const result = await depoc.verifyPayment({ authority: '...', status: 'OK' })

Framework examples

Next.js (App Router)

// lib/depoc.ts
import { DepocStorefront } from '@depoc/storefront-sdk'

export const depoc = new DepocStorefront({
  apiKey: process.env.DEPOC_API_KEY!,
  apiOrigin: process.env.DEPOC_API_ORIGIN,
})

// app/products/[slug]/page.tsx
export async function generateStaticParams() {
  return depoc.getAllProductSlugs()
}

Nuxt 3

// plugins/depoc.ts
import { DepocStorefront } from '@depoc/storefront-sdk'

export default defineNuxtPlugin(() => {
  const config = useRuntimeConfig()
  const depoc = new DepocStorefront({
    apiKey: config.depocApiKey,
  })
  return { provide: { depoc } }
})

Angular

// services/depoc.service.ts
import { Injectable } from '@angular/core'
import { DepocStorefront } from '@depoc/storefront-sdk'
import { environment } from '../environments/environment'

@Injectable({ providedIn: 'root' })
export class DepocService extends DepocStorefront {
  constructor() {
    super({ apiKey: environment.depocApiKey })
  }
}

Astro

---
import { DepocStorefront } from '@depoc/storefront-sdk'

const depoc = new DepocStorefront({
  apiKey: import.meta.env.DEPOC_API_KEY,
})
const homepage = await depoc.getHomepage()
---

API reference

DepocStorefront

| Method | Description | |--------|-------------| | getShopContext() | Branding, modules, profile (requires API key) | | getHomepage() | Aggregated homepage data | | getFeaturedProducts() | Featured product list | | getBanners() | CMS banners | | getCategories({ tree? }) | Category list or tree | | getCategory(slug) | Single category | | getCategoryProducts(slug, filters?) | Products in category | | listProducts(options?) | Paginated product list | | getProduct(slug) | Product detail | | getProductSlugRedirect(slug) | Canonical slug redirect | | searchProducts(query, filters?) | Full-text search | | getAllProductSlugs() | All slugs for SSG | | getAllCategorySlugs() | All category slugs for SSG | | getShippingQuote(items) | Shipping cost quote | | getShippingSettings() | Public shipping config | | getPaymentMethods() | Enabled payment methods | | createOrder(payload) | Place guest order | | initiatePayment(params) | Start online payment (Depoc-hosted) | | completeCardCheckout({ order }) | Create payment + redirect to gateway | | verifyPayment({ authority, status }) | Verify payment on Depoc servers | | getPaymentStatus(paymentId) | Poll payment status | | getDepocPaymentCallbackUrl() | Depoc callback URL (for reference) | | buildPaymentReturnUrls(paths?) | Shop success/failure URLs | | getOrder(orderId) | Order status lookup | | getPublicFileUrl(path) | Public file CDN URL | | resolveAssetUrl(path) | Resolve relative image paths |

Storage helpers

depoc.cart.load()    // CartItem[] from localStorage
depoc.cart.save([])  // Persist cart
depoc.orders.save(order)
depoc.orders.load()

Configuration

| Option | Required | Default | Description | |--------|----------|---------|-------------| | apiKey | Yes | — | Shop API key (depoc_live_...) | | apiOrigin | No | https://api.depoc.ir | API server origin | | siteUrl | No | https://depoc.ir | Your shop website URL | | fetch | No | globalThis.fetch | Custom fetch (Node, edge) | | timeoutMs | No | 30000 | Request timeout | | onError | No | — | Error callback | | performance | No | see below | Dedupe, memo, ETag, retry, keepalive |

Performance

Existing method signatures stay the same. Opt into extra tuning when needed:

const depoc = new DepocStorefront({
  apiKey: process.env.DEPOC_API_KEY!,
  performance: {
    dedupe: true,          // concurrent identical GETs share one network call
    memoTtlMs: 0,          // global GET memo (0 = off; shop/homepage still use short defaults)
    etag: true,            // If-None-Match + 304 body reuse
    retry: { retries: 2 }, // backoff on network / 5xx / 429
    keepalive: true,
  },
})

// Bootstrap warm (parallel)
await depoc.prefetchBootstrap()

// Stale cancellation (search-as-you-type)
const ac = depoc.staleController('search')
await depoc.searchProducts(query, {}, { signal: ac.signal })

// Client-side product batch
const products = await depoc.getProducts(['slug-a', 'slug-b'])

Versioning

This package follows Semantic Versioning:

  • MAJOR — breaking API changes
  • MINOR — new features, backward compatible
  • PATCH — bug fixes

Check SDK_VERSION export or package.json version. Pin in production:

"@depoc/storefront-sdk": "~1.2.0"

Publishing (maintainers)

From monorepo root:

# Install dependencies
npm install

# Build
npm run sdk:build

# Version bump (changesets)
npm run changeset
npm run version-packages

# Publish to npm
npm run release

License

MIT