Skip to main content

Quick Start

npx create-spree-app@latest my-store
The CLI walks you through an interactive setup:
  1. Choose Full-stack (Backend + Next.js Storefront) or Backend only
  2. Optionally load sample data (products, categories, images)
  3. Optionally start Docker services immediately
Once complete, your store is running at http://localhost:3000.

Prerequisites

  • Node.js 20 or later
  • Docker (for running the Spree backend and PostgreSQL)

Setup Modes

Full-stack (default)

Sets up both the Spree backend (Docker) and a Next.js storefront with the Spree SDK pre-configured.
npx create-spree-app@latest my-store
The storefront is downloaded from the Spree Storefront template and placed in apps/storefront/. The CLI automatically:
  • Installs storefront dependencies
  • Fetches a Store API key from the running backend
  • Writes the API key to the storefront’s .env.local

Backend only

Skips the storefront — just the Spree backend and PostgreSQL via Docker. Ideal when you’re building a custom frontend or only need the API.
npx create-spree-app@latest my-store --backend-only

CLI Flags

All prompts can be skipped with flags for non-interactive (CI/CD) usage:
npx create-spree-app@latest my-store --backend-only --no-sample-data --no-start
FlagDescription
--backend-onlySkip storefront setup
--no-sample-dataSkip loading sample products and categories
--no-startDon’t start Docker services after scaffolding
--port <number>Port for the Spree backend (default: 3000)
--use-npmUse npm as package manager
--use-yarnUse yarn as package manager
--use-pnpmUse pnpm as package manager
The package manager is auto-detected from how you run the command. If you use pnpm dlx create-spree-app, pnpm will be used automatically.
If the default port is already in use, the CLI will automatically find a free port and let you know.

Generated Project Structure

my-store/
├── docker-compose.yml    # Spree backend + PostgreSQL
├── .env                  # Backend environment variables
├── .gitignore
├── package.json          # Convenience scripts
├── README.md
└── apps/
    └── storefront/       # Next.js storefront
        ├── .env.local    # API URL + API key
        └── ...

What’s in docker-compose.yml

  • Spree — runs the ghcr.io/spree/spree:latest image on the configured port (default 3000)
  • PostgreSQL 17 — database with persistent volume
  • Health checks on both services

Spree CLI Commands

The project includes @spree/cli for managing your Spree backend:
CommandDescription
spree startStart backend services and stream logs
spree stopStop backend services
spree downStop and remove backend services
spree updatePull latest Spree image and restart (runs migrations automatically)
spree logsView backend logs
spree logs:workerView background jobs logs
spree consoleRails console
spree seedRe-seed the database
spree load-sample-dataLoad sample products, categories, and images

After Setup

Admin Dashboard

Open http://localhost:3000/admin and log in with:
Emailspree@example.com
Passwordspree123

Store API

The REST API is available at http://localhost:3000/api/v3/store. See the API Reference for details.

Storefront (full-stack mode)

If you chose full-stack mode, start the storefront in a separate terminal:
cd my-store/apps/storefront
npm run dev
Open http://localhost:3001 to see your store.

Manual Start

If you used --no-start, start services manually:
cd my-store
spree start
Wait for Spree to be healthy, then optionally load sample data:
spree load-sample-data

Spree CLI

You can also use the Spree CLI directly for additional commands:
spree user create          # Create an admin user
spree api-key create       # Create an API key
spree api-key list         # List API keys

Updating Spree

To update to the latest Spree version:
spree update
This pulls the latest Docker image and recreates the containers. The entrypoint automatically runs database migrations. To pin a specific version, edit SPREE_VERSION_TAG in .env:
SPREE_VERSION_TAG=5.4

Next Steps