Installation
Install the DashForDevs SDK via npm and configure your project.
Updated
On this page
Install the SDK
Install the DashForDevs SDK directly from GitHub:
npm install github:CodeCraftStudios/dash4devs-sdk
Or with yarn:
yarn add github:CodeCraftStudios/dash4devs-sdk
Set Up Environment Variables
Create a .env.local file in your project root:
# Public key — safe for browser/client-side code
NEXT_PUBLIC_DASH4DEVS_API_KEY=pk_live_your_public_key_here
# Secret key — server-side ONLY (API routes, server components)
# NEVER prefix with NEXT_PUBLIC_
DASH4DEVS_SECRET_KEY=sk_live_your_secret_key_here
sk_*) in a NEXT_PUBLIC_ variable. The SDK will throw an error if it detects this, but prevention is better than detection.
Initialize the Client
Create a file at lib/dash.ts (or lib/dash.js):
import { DashClient } from "dash4devs"
export const dash = new DashClient({
apiKey: process.env.NEXT_PUBLIC_DASH4DEVS_API_KEY!,
})
export default dash
For server-side operations that need write access (creating orders, updating customers), create a separate server client:
// lib/dash-server.ts — ONLY import this in server components / API routes
import { DashClient } from "dash4devs"
export const dashServer = new DashClient({
apiKey: process.env.DASH4DEVS_SECRET_KEY!,
})
Verify It Works
Test the connection in any page or component:
import dash from "@/lib/dash"
// Fetch products
const { products } = await dash.products.list()
console.log(products)
If you see your products logged, you are good to go.
Project Structure
Recommended file structure for a DashForDevs storefront:
my-storefront/
app/
layout.tsx
page.tsx # Home page
products/
page.tsx # Product listing
[slug]/page.tsx # Product detail
cart/page.tsx # Cart page
checkout/page.tsx # Checkout
account/
page.tsx # Customer account
orders/page.tsx # Order history
blog/
page.tsx # Blog listing
[slug]/page.tsx # Blog post
lib/
dash.ts # Public client (pk_*)
dash-server.ts # Server client (sk_*)
components/
ProductCard.tsx
CartDrawer.tsx
Header.tsx
Footer.tsx
.env.local # API keys (git-ignored)
TypeScript Support
The SDK ships with full TypeScript definitions. All methods, parameters, and return types are typed. No additional @types package needed.
Next Steps
Now that the SDK is installed, head to the Quick Start guide to build your first page, or check API Keys & Authentication to understand the key types.