Skip to main content

Environment Variables

Set these variables in your hosting platform’s dashboard or .env file.

Required

These are server-side only variables — no NEXT_PUBLIC_ prefix needed since all API calls happen in Server Actions.

Optional

Production Build

The build output is a standalone Next.js application. The npm start command starts the production server.

Vercel

Vercel is the recommended deployment platform for Next.js applications.

One-Click Deploy

  1. Push your code to GitHub
  2. Go to vercel.com/new and import your repository
  3. Add environment variables (SPREE_API_URL, SPREE_PUBLISHABLE_KEY)
  4. Click Deploy
Vercel automatically detects the Next.js framework and configures the build settings.

Vercel CLI

Preview Deployments

Every pull request gets a unique preview URL, making it easy to test storefront changes before merging. Add your Spree API environment variables to the Vercel project settings so previews connect to your staging API.

Docker

Create a Dockerfile in your project root:
Enable standalone output in your next.config.ts for Docker deployments:
Build and run:

Self-Hosted Node.js

For any platform that supports Node.js (Render, Railway, Fly.io, AWS, etc.):
  1. Install dependencies and build:
  1. Start the production server:
The server listens on port 3000 by default. Set the PORT environment variable to change it.

CI/CD

GitHub Actions

Performance Checklist

Before going to production, verify:
  • API URL points to your production Spree instance (not localhost)
  • HTTPS is enabled on both the storefront and the Spree API
  • CORS is configured on your Spree API to allow requests from your storefront domain
  • Sentry is configured for error monitoring (SENTRY_DSN)
  • GTM/GA4 is set up for analytics (GTM_ID)
  • Cookie security — the storefront uses secure: true for cookies in production (NODE_ENV=production)
  • Caching — Next.js cache tags are used for efficient revalidation; review your caching strategy for high-traffic stores