Embedding Sanity Studio in Astro site returns 404 error

18 replies
Last updated: Nov 29, 2025
Hi there,I’m trying to embed the sanity studio into my new astro site.
I’ve followed along with this
documentation , but keep getting a 404 error.
I have the studio installed in a ‘admin’ folder in the root folder of my astro project.
Is there an issue with my astro config?



import { defineConfig } from 'astro/config';
import tailwind from '@astrojs/tailwind';
import svelte from '@astrojs/svelte';
import sanity from 'astro-sanity';
import react from '@astrojs/react';

import netlify from "@astrojs/netlify/functions";

// <https://astro.build/config>
export default defineConfig({
  output: 'hybrid',
  integrations: [tailwind(), svelte(), sanity({
    projectId: '<actualProjectID>',
    dataset: 'production',
    useCdn: false,
    studioBasePath: '/admin'
  }), react()],
  adapter: netlify()
});
AI Update

I can see the issue! You're using the wrong npm package. The astro-sanity package you have in your config is an unofficial/older community package, but Sanity has an official integration called @sanity/astro that you should be using instead.

Here's what you need to do:

1. Uninstall the old package and install the official one:

npm uninstall astro-sanity
npm install @sanity/astro

2. Update your astro.config.mjs:

import { defineConfig } from 'astro/config';
import tailwind from '@astrojs/tailwind';
import svelte from '@astrojs/svelte';
import sanity from '@sanity/astro';  // Changed this line
import react from '@astrojs/react';
import netlify from "@astrojs/netlify/functions";

export default defineConfig({
  output: 'hybrid',
  integrations: [
    tailwind(), 
    svelte(), 
    sanity({
      projectId: '<actualProjectID>',
      dataset: 'production',
      useCdn: false,
      studioBasePath: '/admin'
    }), 
    react()
  ],
  adapter: netlify()
});

3. Verify your Studio setup:

Make sure your admin folder contains a proper Sanity Studio setup with:

  • sanity.config.ts (or .js) file
  • Your schema types
  • Proper basePath configuration in the Studio config

The official Astro documentation shows the correct setup process. The @sanity/astro package is the maintained, official integration that properly handles embedding the Studio at a custom path like /admin.

The 404 error you're experiencing is likely because astro-sanity doesn't have the same Studio embedding capabilities as the official @sanity/astro package. After switching packages, your /admin route should work correctly!

Show original thread
18 replies

Sanity – Build the way you think, not the way your CMS thinks

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.

Was this answer helpful?