Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.quickshops.app/llms.txt

Use this file to discover all available pages before exploring further.

The Quickshops SDK works in any JavaScript framework that gives you a server-side execution context — loaders, server components, server actions, or API routes. The pattern is the same everywhere: instantiate the client once with your API key, then call methods in your server boundary and pass the results to your UI.
Always call the SDK inside a server-side context: a Server Component, loader, server action, or API route handler. The SDK must never run in the browser.
Next.js App Router gives you three natural places to call the SDK: Server Components for read operations, Server Actions for mutations, and Route Handlers for custom API endpoints.1. Create the shared client
lib/quickshops.ts
import Quickshops from "@quickshops/sdk";

export const qs = new Quickshops({
  apiKey: process.env.HEADLESS_API_KEY!,
});
2. Fetch data in a Server Component
app/page.tsx
import { qs } from "@/lib/quickshops";

export default async function Page() {
  const [store, products] = await Promise.all([
    qs.store.get(),
    qs.products.getAll(),
  ]);

  return (
    <main>
      <h1>{store.name}</h1>
      <ul>
        {products.data.map((p) => (
          <li key={p._id}>{p.name}</li>
        ))}
      </ul>
    </main>
  );
}
3. Mutate cart state in a Server Action
app/actions.ts
"use server";

import { qs } from "@/lib/quickshops";

export async function addToCartAction(
  cartId: string,
  productId: string,
  quantity: number,
) {
  return qs.cart.addLine(cartId, productId, quantity);
}