1. Initialize the template#
Click the Sanity template link -- OR -- install with the Sanity CLI:
npm create sanity@latest -- --template=nuotsu/sanitypress-with-typegenSanity template link: https://www.sanity.io/get-started?template=sanitypress-with-typegen&ref=templates-sanitypress-with-typegen
2. Set environment variables#
If initialized via the Sanity template link, the .env.local file should be created automatically.
If initialized via the CLI, duplicate the .env.example file as .env.local and assign the variables to your project:
NEXT_PUBLIC_BASE_URL="https://example.com" # your website's domain
NEXT_PUBLIC_SANITY_PROJECT_ID="abcd1234" # Sanity project id
NEXT_PUBLIC_SANITY_DATASET="production" # Sanity dataset name
SANITY_API_READ_TOKEN="..." # API token with "Viewer" permissionsβ οΈ Required: Set NEXT_PUBLIC_BASE_URL to your production domain.3. Install and start local server#
Install required packages and dependencies with your desired package manager (e.g. npm, pnpm, deno, bun, etc.).
npm run installOnce installed, run the development script to start the local server:
npm run devand open:
- Next.js frontend: http://localhost:3000
- Sanity Studio: http://localhost:3000/admin
4. Add content into your Sanity Studio#
Publish the required documents: site and page (with the slug "index"). More details below:
| Document | Slug or Path | Usage | Required? | Notes |
|---|---|---|---|---|
site |
Global settings | Yes | ||
page |
index |
Homepage route | Yes | |
page |
404 |
Not found route | ||
page |
blog |
Blog listing route | Add the Blog frontpage module | |
global-module |
blog/ |
Blog post template | Add the Blog post content module |
5. Set up deployments#
Add a Vercel (default) or Netlify widget to enable deployments from the Studio.
6. Customize#
Adjust frontend styles to your liking, edit or add new schema and modules, etc.