@spree/next package provides a complete Next.js integration for Spree Commerce with server actions, automatic cookie management, and full TypeScript support.
Installation
Configuration
Auto-initialization
Set environment variables and the client initializes automatically:Explicit initialization
Data Functions
Plain async functions for reading data in Server Components. Wrap with"use cache" in your app for caching.
Products
Categories
Store & Geography
Using in Server Components
Server Actions
Server actions handle mutations and auth-dependent reads. They automatically manage cookies for cart tokens and JWT authentication.Cart
Checkout
All checkout functions takeorderId as the first argument:
Authentication
Addresses
Orders
Payment Sessions
Payment Setup Sessions
For saving payment methods outside of checkout (e.g., “Add a credit card” in account settings):Credit Cards & Gift Cards
Using Server Actions in Forms
Localization
Automatic (recommended)
Data functions automatically read locale and country from cookies. Use the included middleware to set cookies based on the URL:setLocale server action in country/language switchers:
Manual override
You can still pass locale options explicitly — they override the auto-detected values:TypeScript
All types are re-exported from@spree/sdk:

