How tinloof/sanity-kit works
Project type and purpose
• This is a monorepo (managed by pnpm & Turbo) containing a set of npm packages and two demo applications.
• Its purpose is to provide reusable components, plugins and tooling (“Sanity Kit”) for building content‐driven websites with Sanity.io:
• packages/sanity-studio – custom Sanity Studio plugins and components
• packages/sanity-web – React components/utilities for rendering Sanity content in a Next.js front end
• plus shared ESLint & TypeScript config packages
• The apps/next and apps/studio folders are live preview/demo apps to validate changes in sanity-web and sanity-studio respectively.
File structure
• Top level
• monorepo config: pnpm-workspace.yaml, turbo.json, GitHub workflows, root package.json
• packages/: reusable libraries
• apps/: two Next.js-based preview applications
• apps/next
• Next.js front end
• Uses sanity-web package to fetch and render data from a Sanity headless CMS via Sanity API
• Routes for draft–publish toggling via API routes
• apps/studio
• Sanity Studio authored in TypeScript
• Uses sanity-studio package to extend Studio with custom fields, plugins, navigators
• Shared tooling packages under packages/: ESLint config, TypeScript config
• CI/CD: GitHub Actions workflows for changeset-driven releases and dependency updates
README for additional insights
• Describes developer workflow: npm run dev at root spins up all packages and both apps in dev mode via Turbo
• Each app requires its own .env to connect to a real Sanity project
• Changes in packages hot-reload in the corresponding app
a. Main components
• Monorepo root (Turbo/NX orchestrator)
• Package libraries (sanity-studio, sanity-web, eslint-config, typescript-config)
• Preview applications (Next.js front end + API routes; Sanity Studio front end)
• External service: Sanity.io (hosted headless CMS + database)
• Developer workstation (IDE, local environment)
b. Relationships & data flows
1. Developer edits code → Turbo watches & rebuilds affected packages
2. Changes are published to local dev servers in apps/next and apps/studio
3. apps/next → fetches content from Sanity API using sanity-web client
4. apps/studio → connects to Sanity project, extends the editing UI with sanity-studio plugins
5. Both apps read common config (eslint, tsconfig) from root/packages
c. Architectural patterns/design principles
• Monorepo with shared build/config tooling (DRY principle)
• Package-based modularization for reuse across multiple apps
• Preview apps as integration tests
• API façade in Next.js (/api/draft, /api/disable-draft)
d. Key technologies/frameworks/libraries
• pnpm & Turbo – monorepo management and task orchestration
• Next.js – React server/client components + API routes
• Sanity.io – headless CMS (client & CLI SDK)
• TypeScript – type safety across packages and apps
• ESLint/Prettier – code style enforcement
• Tailwind CSS – styling in Next.js apps
Essential architectural elements
• Don’t just list every file—group by package/app and role
• How changes propagate from code → local packages → preview apps → external CMS