- Run
pnpm create next-app@latest my-new-app
- Select your nextjs options
- cd into your app
cd my-new-app
- Create a new sanity project, embed the studio and create all the config files, from the cli
pnpm dlx sanity@latest init --create-project "My New App" --dataset production
- Select your configuration options for your sanity project as well as the route for the embedded studio.
Optional Steps
Add the scripts to generate types from your schemas and queries, to your package.json.
"updateSchemaTypes": "sanity schema extract --enforce-required-fields",
"generateQueryTypes": "sanity typegen generate",
"generateTypes": "pnpm updateSchemaTypes && pnpm generateQueryTypes",
Now you can run pnpm generateTypes every time you update your schemas or add a new query using defineQuery function from next-sanity, and you can get typed queries.
Now you're all setup and ready to go!
Happy coding!
Top comments (0)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.