DevelopersGuide
Install and configure
One client, a handful of options, sensible defaults.
1 min readUpdated View as Markdown
On this page
npm install github:CodeCraft-Studios-LLC/dashfordevs-sdk#v0.3.3The package ships compiled ES modules and is safe to import on the server and in the browser (every browser API is guarded). No transpilePackages needed in Next.js.
import { DashClient } from "dash4devs";
const dash = new DashClient({ apiKey: process.env.NEXT_PUBLIC_DEVDASH_PUBLIC_KEY! });Options
| Option | Default | What it does |
|---|---|---|
apiKey |
required | A pk_ key in the browser, a sk_ key on the server. |
baseURL |
https://papi.dashfordevs.com |
The API host. A localhost URL is kept for local development. |
timeoutMs |
15000 |
Per-request timeout. 0 disables it. |
retries |
2 |
Retries for GET and HEAD on network errors, timeouts and 408, 425, 429, 502, 503, 504. Writes never retry. |
analytics |
private | First-party analytics is de-identified by default. |
Caching in Next.js
In production builds, anonymous GETs use the Next.js data cache with revalidate: 60 and the tag dash4devs. Change the window with DASH4DEVS_REVALIDATE. To refresh on demand, mount the revalidate handler. It only acts on requests that carry your secret:
// app/api/revalidate/route.ts
import { createRevalidateHandler } from "dash4devs";
export const POST = createRevalidateHandler({ secret: process.env.REVALIDATE_SECRET });Entry points
| Import | Contents |
|---|---|
dash4devs |
DashClient, DashApiError, createRevalidateHandler, every module, all types |
dash4devs/react |
DashProvider, useDash, CartProvider, useCart, AuthProvider, useAuth, DashImage, SignaturePad, useDashForm, MaintenancePage |
dash4devs/utils |
price, loyalty and bulk-discount helpers, cdnImageUrl |
dash4devs/security |
assertServerOnlyKey, maskKey, consoleWarningScript |
dash4devs/processors |
client-side payment helpers (Authorize.net Accept.js, Google Pay) |
Keep reading
Something wrong or missing on this page? Email support@dashfordevs.com.