Skip to content

meredithlampe/nextjs-sanityv3

Repository files navigation

Important files and folders

File(s) Description
sanity.config.ts Config file for Sanity Studio
sanity.cli.ts Config file for Sanity CLI
/pages/studio/[[...index]]/page.tsx Where Sanity Studio is mounted
/pages/api/draft.ts Serverless route for triggering Draft mode
/schemas Where Sanity Studio gets its content types from
/plugins Where the advanced Sanity Studio customization is setup
/lib/sanity.api.ts,/lib/sanity.image.ts Configuration for the Sanity Content Lake client

Configuration

run

 npm -y create sanity@latest
 ? Select dataset to use production
? Would you like to add configuration files for a Sanity project in this Next.js folder? Yes
? Do you want to use TypeScript? Yes
? Would you like an embedded Sanity Studio? Yes
? Would you like to use the Next.js app directory for routes? No
? What route do you want to use for the Studio? /studio
? File /pages/studio/[[...index]].tsx already exists. Do you want to overwrite it? No
? File /sanity.config.ts already exists. Do you want to overwrite it? No
? File /sanity.cli.ts already exists. Do you want to overwrite it? No
? Select project template to use Clean project with no predefined schemas
? Would you like to add the project ID and dataset to your .env file? Yes

Add http://localhost:3000 and https://vercel-project-name.vercel.app with credentials to Sanity CORS origins

Run Next.js locally in development mode

npm install && npm run dev

When you run this development server, the changes you make in your frontend and studio configuration will be applied live using hot reloading.

Your personal website should be up and running on http://localhost:3000! You can create and edit content on http://localhost:3000/studio.

Deploy via vercel

Add a new project in Vercel, then add the project details to a new 'Project' under the 'Deploy' tab in Sanity studio