@thorprovider/core
v1.0.4
Published
Thor Commerce core infrastructure template. Used as base for V0-generated starters.
Readme
title: Core Package purpose: Documentation for @thorprovider/core storefront template description: Next.js storefront template with headless commerce
[App Name]
Next.js 16 storefront with headless commerce. Commerce, auth, i18n, and theming are pre-configured via @thorprovider/* packages — just connect your backend and build features.
🚀 Development Workflow
Step 1: Create the App (Local)
# Minimal
yarn create:app --name my-store
# With backend pre-configured
yarn create:app --name my-store \
--commerce-provider medusa \
--commerce-api-url https://your-backend.com \
--commerce-api-key pk_live_xxx \
--preset electro \
--site-url https://my-store.com \
--generate-regions
cd projects/my-storeThis command:
- Clones
@thorprovider/coreintoprojects/my-store/ - Installs dependencies
- Generates
.envfrom.env.example(backend flags inject values directly) - Patches
config/site.config.tswith--presetand--site-urlif provided - Optionally runs region generation (
--generate-regions) to pre-populatelib/regions-config.ts - Initializes git with an initial commit
- Generates
.v0-context.md(contains frozen architecture files)
Configure your backend (if you didn't use CLI flags):
nano .env
# Set: NEXT_PUBLIC_COMMERCE_API_URL=https://your-backend.com
# NEXT_PUBLIC_COMMERCE_API_KEY=pk_live_xxxTest locally:
yarn dev
# → http://localhost:3000Step 2: Connect to GitHub
- Create a new repo on GitHub (without README, .gitignore, or license)
- In your local app directory, add the remote and push:
git remote add origin https://github.com/your-org/your-repo.git
git branch -M main
git push -u origin mainThis repository is auto-generated by create:app from @thorprovider/core—it contains frozen architecture files that must not be modified manually. See "Frozen Files" below.
Step 3: Use V0 for Feature Development
- Copy
.v0-context.md(in this repo root) into your first message on v0.app - Connect your GitHub repo to V0 (V0 will pull from the remote)
- Paste the entire
.v0-context.md— it tells V0 which files are frozen and which patterns to follow - Describe your feature in subsequent messages (e.g., "Add product filters to the product list page")
- V0 generates code respecting the frozen architecture and
@thorprovider/*package constraints - Review the PR, merge to main, and deploy to Vercel
Example first message on v0.app:
[Paste full .v0-context.md here]
Now, create a product filter sidebar for the /products page that filters by category and price range.Step 4: Deploy
After merging changes to main, deployment happens automatically (if you've connected Vercel).
🔒 Frozen Files (Do NOT Modify)
These files define the app's architecture and are frozen by design. V0 respects these; you must too:
| File | Purpose |
|------|---------|
| lib/commerce.ts | Commerce provider initialization (singleton) |
| lib/commerce-provider.tsx | CommerceProvider context wrapper |
| lib/region-provider.tsx | RegionProvider context wrapper |
| lib/auth-context.tsx | Authentication context |
| lib/cart-provider.tsx | CartProvider context wrapper |
| lib/storefront-config.ts | Backend-driven storefront config fetch (theme accent, cached) |
| lib/region-detection.ts | IP-based region detection from Vercel/Cloudflare geolocation headers |
| components/providers/app-providers.tsx | Provider hierarchy (order is critical) |
| components/providers/navigation-provider.tsx | NavigationProvider wrapper |
| app/layout.tsx | Root layout (ThemeProvider + AppProviders + IP region detection) |
| config/site.config.ts | Site configuration (values can change, shape is frozen) |
Why frozen? Changing these breaks the L1–L5 architecture. If you need to modify one, you're likely breaking a constraint. Read docs/rules.md first.
What's Pre-Configured
- Regional commerce (IP-based region detection via Vercel/Cloudflare geolocation headers)
- Shopping cart (persistent, backend-synced via
lib/cart-provider.tsx) - Authentication (JWT via
lib/auth-context.tsx) - Dark mode + CSS token theming + backend-driven accent color override (
lib/storefront-config.ts) - Circuit breaker (auto-fallback when backend is unavailable, auto-resets after 60s)
- Webhook ISR revalidation (
app/api/revalidate/route.ts, opt-in viaFRONTEND_WEBHOOK_SECRET) @thorprovider/componentsUI library (55 accessible components)
📚 Documentation
For Humans (You)
Read in this order:
- docs/README.md — Overview + capabilities
- docs/project-structure.md — Where files live
- docs/patterns.md — How to write pages, fetch data, style components
For V0 / AI Agents
Copy .v0-context.md to V0's first message. It includes:
- Frozen architecture files (do not modify)
- Type shapes for all domain objects
- Method signatures for all
commerce.*calls - Pre-commit checklist
Then read docs/ in order:
- docs/project-structure.md
- docs/dependencies.md — 55 available components
- docs/types.md — Product, Cart, Order, Customer, Address shapes
- docs/commerce-api.md — getProducts(), createCart(), etc.
- docs/patterns.md — Server/client, fetch patterns
- docs/rules.md — Non-negotiable constraints
Deployment
Vercel: Connect repo → set env vars (NEXT_PUBLIC_COMMERCE_API_URL, NODE_AUTH_TOKEN) → deploy.
Self-hosted: yarn build && yarn start with env vars set in host.
Troubleshooting
Module not found: @thorprovider/* → Verify NODE_AUTH_TOKEN has read:packages scope, then yarn install.
Backend unavailable / circuit breaker → Check NEXT_PUBLIC_COMMERCE_API_URL and network connectivity. Auto-resets after 60s.
