Skip to Content
devhelp shopDocs

@devhelp/shop SDK

Typed TypeScript client for Storefront, Admin, React, Next.js, and Webhooks.

@devhelp/shop is the official TypeScript SDK generated from the same oRPC contract that powers api.devhelp.pk.

pnpm add @devhelp/shop

Entry points

Import pathPurposeRuntime
@devhelp/shopcreateShopClient, ShopError, isShopError, formatMoney, paisa, and domain typesBrowser, Node, Edge
@devhelp/shop/servercreateAdminClient with Secret Key (dh_sk_live_…) and automatic Idempotency-Key supportServer only
@devhelp/shop/reactTanStack Query hooks for storefront data fetchingReact / Client
@devhelp/shop/nextcreateShopServer, cookieCartStorage, shopTags, and createWebhookHandler for Next.js webhook cache revalidationNext.js App Router
@devhelp/shop/webhooksverifyWebhook, signWebhook, WEBHOOK_TOPICS, SUBSCRIBABLE_TOPICSBrowser, Node, Edge

Storefront client (@devhelp/shop)

import { createShopClient, localStorageStorage } from "@devhelp/shop";

export const shop = createShopClient({
  baseUrl: "https://api.devhelp.pk",
  publishableKey: process.env.NEXT_PUBLIC_DEVHELP_PUBLISHABLE_KEY!,
  storage: typeof window !== "undefined" ? localStorageStorage() : undefined,
});

const store = await shop.store.get();
const { items } = await shop.products.list({ limit: 24 });

Admin client (@devhelp/shop/server)

import { createAdminClient } from "@devhelp/shop/server";

export const admin = createAdminClient({
  baseUrl: "https://api.devhelp.pk",
  secretKey: process.env.DEVHELP_SECRET_KEY!,
});

const { items: orders } = await admin.orders.list({ limit: 20 });

Next.js App Router helpers (@devhelp/shop/next)

createShopServer tags catalog fetches with Next.js cache tags while keeping cart, checkout, and order requests uncached (no-store). cookieCartStorage stores cart tokens in httpOnly cookies:

import { cookies } from "next/headers";
import { createShopServer } from "@devhelp/shop/next";

export async function getShopServer() {
  return createShopServer({
    baseUrl: "https://api.devhelp.pk",
    publishableKey: process.env.NEXT_PUBLIC_DEVHELP_PUBLISHABLE_KEY!,
    cookies: await cookies(),
  });
}

On this page