@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/shopEntry points
| Import path | Purpose | Runtime |
|---|---|---|
@devhelp/shop | createShopClient, ShopError, isShopError, formatMoney, paisa, and domain types | Browser, Node, Edge |
@devhelp/shop/server | createAdminClient with Secret Key (dh_sk_live_…) and automatic Idempotency-Key support | Server only |
@devhelp/shop/react | TanStack Query hooks for storefront data fetching | React / Client |
@devhelp/shop/next | createShopServer, cookieCartStorage, shopTags, and createWebhookHandler for Next.js webhook cache revalidation | Next.js App Router |
@devhelp/shop/webhooks | verifyWebhook, signWebhook, WEBHOOK_TOPICS, SUBSCRIBABLE_TOPICS | Browser, 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(),
});
}