- Step 1. Set up the environment
- Step 2. Run Next.js locally in development mode
- Step 3. Populate content
- Next steps
If you started with deploying your own then you can run this to reuse the environment variables from the Vercel project and skip to the next step:
npx vercel link
npx vercel env pullThis far your .env.local file should have values for NEXT_PUBLIC_SANITY_PROJECT_ID and NEXT_PUBLIC_SANITY_DATASET.
Before you can run the project you need to setup a read token (SANITY_API_READ_TOKEN), it's used for authentication when Sanity Studio is live previewing your application.
- Go to manage.sanity.io and select your project.
- Click on the
🔌 APItab. - Click on
+ Add API token. - Name it "next blog live preview read token" and set
PermissionstoViewerand hitSave. - Copy the token and add it to your
.env.localfile.
SANITY_API_READ_TOKEN="<paste your token here>"Your .env.local file should look something like this:
NEXT_PUBLIC_SANITY_PROJECT_ID="r0z1eifg"
NEXT_PUBLIC_SANITY_DATASET="blog-vercel"
SANITY_API_READ_TOKEN="sk..."npm install && npm run devyarn install && yarn devpnpm install && pnpm devThe website should be up and running on http://127.0.0.1:3000!
Open Sanity Studio that should be running on http://127.0.0.1:3000/studio.
Whenever you edit a GROQ query you update the TypeScript types by running:
npm run typegen