✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

How to host both Sanity Studio and Frontend on the same Netlify site

13 replies
Last updated: May 14, 2021
Hey people! how does hosting both your sanity studio and your FE on the same netlify site work? I did find a guide on the guide page but it returned 404. I got the FE up and running but i’d like to access the studio on the same url but like /admin or /dashboard or whatever 🙂 everything is in the same github repo
May 13, 2021, 8:47 AM
Hey Oskar! The process for deploying should be the same as in this guide .You would need to make sure that you’ve configured single-page application routing on Netlify and added the domain where you’re hosting the Studio as a
valid domain in manage.sanity.io . Then, you would specify the
basePath
in
sanity.json
as
/admin
or
/dashboard
May 13, 2021, 6:23 PM
And as a side note, you could add this plugin to easily trigger new builds of your FE from your dashboard!
May 13, 2021, 6:25 PM
Hey Oskar! The process for deploying should be the same as in this guide .You would need to make sure that you’ve configured single-page application routing on Netlify and added the domain where you’re hosting the Studio as a
valid domain in manage.sanity.io . Then, you would specify the
basePath
in
sanity.json
as
/admin
or
/dashboard
May 13, 2021, 6:23 PM
Hey
user M
, thanks for the answer 😄Im not really sure how that would work considering i have to specify the build command and the publish directory.. and if i have a project repo and the structure for it is

project/
    web/
    studio/
how would i go on to setup the build settings for the netlify site?
May 14, 2021, 7:43 PM
Might just be me who doesnt understand it, because atm to only build the FE i set the baseDirectory to
/web
and the build command to
next build && next export
and then the publish directory to
/web/out
So i dont know how to get the sanity folder
/studio
into that solution..
May 14, 2021, 7:46 PM
OK, if I’m understanding correctly, you’re not sure how to get the studio to build at the domain you specify?
If so, you would follow the steps in the guide I shared above then run
sanity deploy
in order to have the studio deploy. You wouldn’t need to include the studio in your next build.
Let me know if I’m getting your goal wrong!
May 14, 2021, 9:07 PM
Okay so what you’re saying is that if i have my github repository (including both the
/web
and
/studio
) on netlify and the build settings is what i stated before, e.g the commands to build the nextjs application, I dont have to do
sanity build
if i want to be able to access the studio on the same netlify url but on
websiteUrl/admin
? I just have to deploy with a specified build path in sanity.json?
May 14, 2021, 9:15 PM
Okay so what you’re saying is that if i have my github repository (including both the
/web
and
/studio
) on netlify and the build settings is what i stated before, e.g the commands to build the nextjs application, I dont have to do
sanity build
if i want to be able to access the studio on the same netlify url but on
websiteUrl/admin
? I just have to deploy with a specified build path in sanity.json?
May 14, 2021, 9:15 PM
Exactly
May 14, 2021, 9:15 PM
Do i have to state the full url or just /admin in the build path?
May 14, 2021, 9:16 PM
It would just be the /admin build path but you would have to add the domain to your CORS origins in manage.sanity.io
May 14, 2021, 9:19 PM
alright sweet! 😄 Thank you so much🤗
May 14, 2021, 9:19 PM
Of course! Good luck!
May 14, 2021, 9:20 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?