This is an example Next.js and Sanity monorepo.
The Next.js application is a simple blog with Visual Editing / Presentation enabled.
This codebase is structured as a monorepo to enable using the Sanity Studio config as both a standalone Studio as well as an embedded Studio. It's using pnpm workspaces and turbo.
├─ apps
│ ├─ studio ............ Sanity studio for the admin studio
│ └─ web ............... Next.js app for the marketing website
└─ packages
├─ eslint-config ..... shared ESLint config
└─ sanity-config ..... admin studio Sanity config
This codebase has some of my own opinions which you might wanna change. It uses:
- Tailwind in the Next.js app
- ESLint with the Prettier plugin
- Husky to enchance commits by:
- Enforcing convential commit messages
- Running linting on staged files
- Checking consistency of dependency versions across packages pre-commit using Syncpack
- Renovatebot to keep dependencies up to date
This repo has a pnpm typegen
command in the root, which will run sanity schema extract
and sanity typegen generate
in the studio
package. This is configured to find GROQ queries from the web
and sanity-config
packages and compile a sanity.types.ts
in the root folder.
To run the website and studio together:
pnpm run dev
To run only the website:
pnpm run dev --filter=web
To run only the admin studio:
pnpm run dev --filter=studio