
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeGreat question! Hosting both your Sanity Studio and frontend on the same Netlify site from a single repo is totally doable. Here's how to set it up:
basePathIn your Sanity Studio config file (sanity.config.ts or sanity.config.js), you need to set a basePath to tell Studio it's living at a sub-route:
import {defineConfig} from 'sanity'
export default defineConfig({
projectId: 'your-project-id',
dataset: 'your-dataset',
basePath: '/admin', // or /studio, /dashboard, whatever you prefer
// ... rest of your config
})You have two main approaches depending on your frontend framework:
If you're using Next.js, create a catch-all route like app/admin/[[...index]]/page.tsx (App Router) or pages/admin/[[...index]].tsx (Pages Router):
// app/admin/[[...index]]/page.tsx
import {Studio} from 'sanity'
import config from '../../../sanity.config'
export default function StudioPage() {
return <Studio config={config} />
}The [[...index]] pattern ensures all sub-routes under /admin get handled by the Studio.
If you're not using a framework with built-in routing (or deploying a static build), you need to configure Netlify redirects. Create a netlify.toml file in your repo root:
[[redirects]] from = "/admin/*" to = "/admin" status = 301 force = true
According to the Sanity embedding documentation, this redirect ensures all routes under /admin are properly handled by the Studio's client-side routing.
Don't forget to add your Netlify domain to your Sanity project's CORS origins settings with credentials enabled. Go to your project settings at manage.sanity.io and add:
https://your-site.netlify.app (production)http://localhost:3000 (or whatever port you use locally)The Studio needs to take full viewport height. Add this CSS wherever your /admin route renders:
#app {
height: 100vh;
max-height: 100dvh;
overscroll-behavior: none;
-webkit-font-smoothing: antialiased;
overflow: auto;
}Since everything's in the same repo, a typical structure looks like:
my-project/ ├── sanity.config.ts # Studio config ├── app/ # Your Next.js app (or other framework) │ └── admin/[[...index]]/page.tsx ├── schemas/ # Sanity schemas ├── netlify.toml # If using redirects └── package.json
For more details, check out the Embedding Sanity Studio docs and the next-sanity library if you're using Next.js specifically.
The setup works great on Netlify - you'll have your frontend at the root and Studio accessible at whatever path you choose! 🎉
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store