@faststore/core
v4.5.1
Published
<p align="center"> <img alt="Faststore" src="../ui/static/logo.png" width="60" /> </p>
Keywords
Readme
@faststore/core is the main Next.js application for FastStore storefronts. It bundles together all the building blocks of a store — sections, pages, SDK hooks, server utilities, and CMS configuration — into a ready-to-use boilerplate.
Store builders consume this package through @faststore/cli and extend it via the src/customizations/ directory. You will work directly in this package when contributing new sections, pages, SDK hooks, or CMS configurations to the FastStore platform.
Package structure
packages/core/
├── src/
│ ├── components/
│ │ ├── sections/ # Full-page content slices (Hero, ProductGallery, ProductShelf…)
│ │ ├── ui/ # Store-level UI components (compositions of @faststore/ui)
│ │ ├── skeletons/ # Loading state skeleton components
│ │ └── … # Domain folders: cart, product, search, navigation, auth…
│ ├── pages/ # Next.js file-based routes
│ ├── sdk/ # Business logic hooks (cart, session, search, analytics…)
│ ├── server/ # Server-side utilities (CMS content fetching)
│ ├── customizations/ # Store-level overrides: styles, fonts, components, fragments
│ ├── styles/ # Global SCSS styles
│ └── instrumentation.ts # Next.js instrumentation hook (boots @faststore/diagnostics when otelEnabled)
├── cms/faststore/ # CMS configuration: sections.json, content-types.json, schemas
├── @generated/ # Auto-generated GraphQL types — do not edit
├── discovery.config.default.js # Committed base store configuration (platform, sales channel, locale)
├── discovery.config.js # Merges default config with store-level customizations — do not edit directly
├── next.config.js # Next.js configuration
├── codegen.ts # GraphQL code generation config
└── lighthouserc.js # Lighthouse CI configurationHow to run
Prerequisites: Node ≥ 20, pnpm
pnpm install
pnpm dev # generates GraphQL types, then starts the Next.js dev serverYour store will be available at http://localhost:3000.
The
pnpm devcommand runspnpm generateautomatically before starting the dev server. You only need to runpnpm generatemanually when you change a GraphQL query or fragment while the server is already running.
How to develop
Adding or modifying a section
Sections are full-page slices that can be managed via the CMS. They live in src/components/sections/.
- Create
src/components/sections/{SectionName}/{SectionName}.tsxand a companion.module.scss - Compose the section using components from
@faststore/ui - Add the section definition to
cms/faststore/sections.json(name, props, schema) - Export the section from the sections index
Adding a store-level UI component
Store-level UI components (not intended for the shared library) live in src/components/ui/.
- Create
src/components/ui/{ComponentName}/{ComponentName}.tsxwith a companion.module.scss - Compose using components from
@faststore/ui - Use TypeScript for props — no
data-fs-*attributes needed here (those belong in@faststore/components)
Adding or modifying a GraphQL query
- Edit or create a
.graphqlfile with your query or fragment - Run
pnpm generateto regenerate types under@generated/ - Import the generated types from
@generated/graphql
Never edit files inside
@generated/manually — they are overwritten on everypnpm generaterun.
Managing SVG icons
Icons are loaded from a single sprite at public/icons.svg via the Icon component from @faststore/ui.
- Open
public/icons.svgand add a new<symbol>with a uniqueid - Remove
fill,stroke-width,width,height, andcolorattributes from the symbol so it can be styled via CSS - Use the icon in any component:
import { Icon } from '@faststore/ui'
<Icon name="Bell" weight="thin" />This project uses icons from Phosphor Icons.
Adding CMS configuration
FastStore currently supports two CMS content sources. The flow depends on which one we want to update.
Headless CMS (legacy)
- Define the section schema in
cms/faststore/sections.json - For new content types, add them to
cms/faststore/content-types.json - Run
pnpm faststore cms-syncto push changes to the CMS
CMS (new)
Schemas are defined as individual .jsonc files instead of a single sections.json.
To support both CMS versions, changes made to the legacy files are migrated to the new format using the split commands.
- After updating
sections.jsonorcontent-types.json, run the split commands to generate the new format:
vtex content split-components -i cms/faststore/sections.json -o cms/faststore/componentsvtex content split-content-types -i cms/faststore/content-types.json -s cms/faststore/sections.json -o cms/faststore/pagesIMPORTANT: The Faststore Core Team is the only one that needs to add the -l base.jsonc to the output. Merchants will automatically use the base from the Schema Registry.
Store developers: set contentSource: { type: 'CP' } in discovery.config.js, place custom schemas under cms/faststore/components/ and/or cms/faststore/pages/, then run:
yarn cms-synccms-sync detects the content source automatically — in CP mode it generates the schema from your customizations and uploads it to the Schema Registry. Use --dry-run to generate locally without uploading.
Before running anything in CP mode, cms-sync checks that the vtex toolbelt is installed and that you are logged into your store's account (api.storeId in discovery.config.js); otherwise it stops with a hint to run vtex login <account> / vtex switch <account>. The toolbelt is interactive: generate-schema asks you to confirm when one of your definitions overrides a base one, and upload-schema asks for the version to publish — answer the prompts in your terminal.
If experimental.enableFaststoreMyAccount is enabled, cms-sync also merges the core My Account schemas (shipped in @faststore/core) into the generated schema. These schemas are intentionally excluded from the published base schema (so they are not in the Schema Registry). The command performs a file-level merge of the core My Account JSONC with your own cms/faststore/{components,pages} into a temporary staging directory under your store's .faststore/ (your files override core on name collision), runs a single generate-schema/upload-schema over it, announces the merge, and removes the staging directory afterwards.
FastStore Core team (publishing the base schema with the core layer):
- Generate the schema:
vtex content generate-schema cms/faststore/components cms/faststore/pages -l cms/faststore/base.jsonc -o cms/faststore/schema.json- Upload the schema to the Schema Registry:
vtex content upload-schema cms/faststore/schema.jsonFiles can be placed in cms/components/ and cms/pages/, or co-located alongside their component in src/components/.
For schema syntax and the full architectural overview, see the CMS architecture and schema declarations guide.
How to test
pnpm test # unit tests (Vitest)
pnpm test:e2e # E2E tests (Cypress)
pnpm lhci # Lighthouse performance auditThis project has strict performance budgets. The Lighthouse CI (lhci) runs automatically on every PR and enforces score minimums and metric budgets defined in lighthouserc.js.
How to publish
This package is versioned and published as part of the FastStore monorepo release process, managed by Lerna at the monorepo root. Do not publish individually.
# From the monorepo root:
pnpm release # publish to latest (main branch)
pnpm release:dev # publish to dev tag (dev branch)