Skip to main content

🧱 Installation

Install the SDK and configure your environment to start building your Shopify headless storefront with Next.js.


📦 Install the package

Use your favorite package manager to add the SDK to your project:

npm install @nextshopkit/sdk

or

yarn add @nextshopkit/sdk

or

pnpm add @nextshopkit/sdk

🌐 Shopify API Access

In your .env.local, define the following variables:

SHOPIFY_ACCESS_TOKEN=your-storefront-access-token
SHOPIFY_STORE_DOMAIN=your-shop.myshopify.com
note

These values are not exposed to the client, so you must use this SDK in server-side code only.

You can get the Storefront Access Token and Store Domain from your Shopify admin:

  • Go to Apps > Develop Apps
  • Create or use an existing private app
  • Enable Storefront API access
  • Copy the generated Access Token

🧠 Suggested Project Structure

We recommend creating a centralized client for typed access and shared options.

Create your Shopify SDK wrapper under:

lib/NextShopKit/client.ts
import {
createShopifyClient,
FetchProductResult,
FetchProductsResult,
GetCollectionOptions,
FetchCollectionResult,
} from "@nextshopkit/sdk";

const client = createShopifyClient({
shop: process.env.SHOPIFY_STORE_DOMAIN!,
token: process.env.SHOPIFY_ACCESS_TOKEN!,
apiVersion: "2025-01",
});

export const getProduct = async (
args: GetProductOptions
): Promise<FetchProductResult> => client.getProduct(args);

export const getCollection = async (
args: GetCollectionOptions
): Promise<FetchCollectionResult> => client.getCollection(args);

export default client;

🛡️ Server-only usage

To avoid leaking your Shopify access token, never use this SDK directly on the client.

Instead, use it:

  • In server components ("use server")
  • In API routes
  • In Route Handlers or app/api (App Router)
DO NOT import the SDK in client components!

Shopify credentials are stored in environment variables and must stay server-side.


🚀 PRO Version (Coming Soon)

The PRO version unlocks advanced features like:

  • Metaobjects
  • Blogs & Articles
  • Product Recommendations
  • Advanced Cart
  • Localization
  • Shopify Search

After purchase, you’ll receive a unique token to unlock PRO features via environment variable.

📄 Setup instructions for PRO are in Installation: PRO →


✅ Next up: Usage →

Description

Learn how to install and configure @nextshopkit/sdk for your Next.js + Shopify headless storefront.