Skip to content

Latest commit

 

History

History
60 lines (42 loc) · 2.41 KB

README.md

File metadata and controls

60 lines (42 loc) · 2.41 KB

This is a guide to explain how to set-up on-demand revalidation in a Sanity Nextjs project. Read the article. Visit the live demo to see the project live.

Live Preview

preview

Prerequisites

This template uses the following versions:

  • Nextjs: v14.0.4
  • next-sanity: v7.0.4
  • sanity: 3.21.3
  • React: v18

Important files and folders

File(s) Description
sanity.config.ts Config file for Sanity Studio
sanity.client.ts Config file for Sanity CLI
studio Where Sanity Studio is mounted
schemas Where Sanity Studio gets its content types from
sanity.query.ts Where Sanity data is described and retrieved
route.ts Route handler for triggering on-demand revalidation

Run project locally

  • clone repository
git clone https://github.com/Evavic44/sanity-nextjs-revalidation.git

cd sanity-nextjs-revalidation

npm install
  • Rename .env.example to .env

Update Env Variables

  • NEXT_PUBLIC_SANITY_PROJECT_ID Set to your project ID

  • NEXT_PUBLIC_SANITY_DATASET Set to "server" or a new project dataset.

  • NEXT_PUBLIC_SANITY_API_VERSION: Set to your current date in YYYY-MM-DD format or leave as is

  • NEXT_PUBLIC_SANITY_ACCESS_TOKEN Visit Sanity Manage to create an access token.

  • NEXT_PUBLIC_SANITY_HOOK_SECRET Visit Sanity Manage > API to create hook secret.

  • Now run npm run dev Visit http://localhost:3000 to see your site
    Visit http://localhost:3000/studio to edit content