A Sanity starter kit providing modern, clean designs for your content-driven websites. Built with Next.js and Tailwind CSS.
Out of the box it includes schema for pages, posts, categories, authors, and global settings. Pages are structured with a page builder that lets you compose a number of components: hero, CTA, post list, subscribe, content, etc.
- Next.js
- Sanity
- Tailwind CSS
- Shadcn/ui
- React
- TypeScript
- Vitest
npm create sanity@latest -- --template 10up/sanity-ignite
This will install your NPM dependencies and populate the .env.local
file.
npm run dev
Open the next app locally at http://localhost:3000 and the Sanity Studio at http://localhost:3000/studio.
π₯ sanity-ignite
βββ π src # Main source code directory
β βββ π app # Next.js application
β β βββ π (frontend) # Frontend routes
β β βββ π studio # Sanity Studio route
β β βββ π api # API routes (Next.js route handlers)
β βββ π components # UI components and icons
β β βββ π icons # Custom SVG/icon components
β β βββ π ui # Presentational UI components with no side effects
β β βββ π modules # Components that receive Sanity data and may call server actions
β β βββ π sections # Page builder sections
β β βββ π templates # Page templates
β βββ π hooks # Custom react hooks
β βββ π actions # Server-side actions
β βββ π env # Environment specific functions and `.env` validation
β βββ π lib # Shared libraries and integrations
β β βββ π sanity # Sanity integration
β β β βββ π queries # Sanity GraphQL/GROQ queries
β β β βββ π client # Sanity client configuration
β β βββ π (example) # Every integration (e.g., CRM, Newsletter SDKs) gets its own subfolder
β βββ π studio # Sanity Studio configuration
β β βββ π schemas # Schema definitions for Sanity content models
β β βββ π components # Custom Sanity components
β β βββ π plugins # Custom Sanity plugins
β β βββ π structure # Custom Sanity structure definitions
β βββ π utils # Utility functions and TypeScript types
-
ui/
- Presentational UI Components- This folder contains pure UI components that have no side effects.
- Components here can be used both in client and server components.
- π« Do not use: Sanity types, data fetching, or global state within these components.
-
modules/
- Components that Accept Sanity Data- These components receive data from Sanity queries and might contain logic to manipulate or render that data.
- No direct data fetching should happen inside these components.
- They can, however, call server actions that fetch or modify data.
-
sections/
- Page Builder Sections- Large, structured UI sections that form reusable parts of pages.
- Used to assemble pages dynamically in a CMS-driven way.
-
templates/
- Page Templates- Higher-level layout structures that can be shared between multiple routes.
-
icons/
- Custom SVG/Icon Components- Collection of SVG-based components used throughout the UI.
- Icons should be stored as SVG files and imported as React components. Icons should NOT be added as React components directly.
-
sanity/
- Sanity Integrationqueries/
β Contains all Sanity GROQ queries used in the frontend.client/
β Configures the Sanity client and SanityLive client used for API calls
-
(example)/
- External Service Integrations- Each external service (e.g., CRM, Newsletter SDKs) should have its own subfolder under
lib/
. - Example:
/lib/newsletter/
for newsletter subscriptions,/lib/crm/
for CRM integrations.
- Each external service (e.g., CRM, Newsletter SDKs) should have its own subfolder under
This folder contains everything needed to configure and customize Sanity Studio, the headless content operating system used in this project.
-
schemas/
- Content Models- Defines the schema of content in Sanity (e.g.,
Post
,Author
,Category
).
- Defines the schema of content in Sanity (e.g.,
-
components/
- Custom Sanity Components- Custom React components that enhance the Sanity Studio interface.
- These might include custom inputs, preview components, or UI overrides.
-
plugins/
- Sanity Plugins- Third-party or custom plugins that extend Sanityβs functionality.
- Examples: AI-powered content suggestions, media management, or real-time collaboration tools.
-
structure/
- Custom Studio Structure- Defines how content is organized inside the Sanity Studio UI.
- Custom menus, navigation rules, and UI layouts are configured here.
The project uses environment variables to store configuration values that differ between environments (e.g., local development, testing, and production). These variables are stored in .env
files, which Next.js loads automatically. Read more on the Nex.js Docs here.
File | Purpose |
---|---|
.env.local |
Stores local environment variables. This file is git-ignored and should not be committed. |
.env.example |
A template for environment variables. It lists required variables without actual values. |
.env.test |
Contains environment variables used specifically for running unit tests. |
Before running the project locally, copy .env.example
and create a .env.local
file:
cp .env.example .env.local
Then, fill in the required values based on your local setup.
This project uses valibot for schema validation of environment variables. To add a new environment variable:
- Update the
.env.example
file - Add the new variable to the
envSchema
object insrc/env/serverEnv.ts
orsrc/env/clientEnv.ts
All environment variables should be accessed using the serverEnv
or clientEnv
objects.
Example:
const projectId = serverEnv.NEXT_PUBLIC_SANITY_PROJECT_ID;
π‘ Public vs. Private Variables:
- Variables prefixed with
NEXT_PUBLIC_
are exposed to the browser and can be used in client-side code. Validation of these variables is done insrc/env/clientEnv.ts
. - Variables without
NEXT_PUBLIC_
remain server-only. Validation of these variables is done insrc/env/serverEnv.ts
.
When running unit or integration tests, the .env.test
file is loaded automatically.
βοΈ Never commit .env.local
! It's ignored by .gitignore
.
βοΈ Use .env.example
to document required variables without exposing secrets.
βοΈ Keep private keys and API secrets out of NEXT_PUBLIC_
variables.
This project uses ESLint and Prettier for code linting and formatting. Run the following commands to lint and format your code:
npm run lint # Lint the code
This project has custom ESLint rules configured for the following scenarios:
- Sanity Studio
next-sanity
package cannot be imported into the studio. This is a frontend only package.
- Next.js Frontend
- Assets from the sanity studio or from studio related packages cannot be imported into the frontend. They can only be used in the
sanity.config.ts
file or in thesrc/studio
folder. This is to prevent the frontend from loading unoptimized studio assets.
- Assets from the sanity studio or from studio related packages cannot be imported into the frontend. They can only be used in the