Discussion about deploying Sanity Studio with Vercel and encountering issues.
20 replies
Last updated: Feb 24, 2022
N
Any update on this?
Feb 11, 2022, 6:42 PM
J
Good day, User. Instead of the build
distdirectory, try either leaving root directory blank if you’re deploying your studio directly or entering the directory where your
studio.jsonand
package.jsonare located
Feb 11, 2022, 9:39 PM
N
user U
I have removed and left Root Directory empty now. When deploying withwith
{ "version": 2, "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }] }
Feb 11, 2022, 11:44 PM
J
I’ve had a lot of success just going over the basic sanity studio + vercel instructions, so I’m using that as a guide. And I’m currently reviewing the recently published medium2.0 ISR youtube video from User. So I’ll publish this studio to vercel…
https://vercel.com/guides/deploying-sanity-studio-with-vercel
I’m not using any real monorepo methods, I just have two directories in my project - one for studio and one for frontend. Following instructions, I’ve created a
https://vercel.com/guides/deploying-sanity-studio-with-vercel
I’m not using any real monorepo methods, I just have two directories in my project - one for studio and one for frontend. Following instructions, I’ve created a
vercel.jsonfile in the studio root, added
public -yto the build script in package.json. And added
@sanity/clias a dev dependency.
Feb 11, 2022, 11:58 PM
N
user U
Followed this tutorial did exactly the same but not working very weird….Feb 12, 2022, 12:00 AM
J
Since I am not currently using lerna or package mgr features to actually merge the sites, they are simply TWO web projects nested in the same repo.
I am going to deploy JUST the studio for now, pointing the vercel deployment tool at my github repo and then setting the updated root directory in my case to
I am going to deploy JUST the studio for now, pointing the vercel deployment tool at my github repo and then setting the updated root directory in my case to
/studio
sanity cors add <https://your-url.vercel.app> --credentials
Feb 12, 2022, 12:03 AM
J
this is not an ideal way to manage front and backend sites in a single repo - but just for learning and testing should work well enough
Feb 12, 2022, 12:04 AM
J
and the cherry on top that I always tend to forget - is adding the cors address to my sanity project info, most handily via the cli in the command in my previous post
Feb 12, 2022, 12:06 AM
J
Also don’t forget• run studio build in your local environment just to be sure
• git add, commit, push — then actually run the vercel build
• git add, commit, push — then actually run the vercel build
Feb 12, 2022, 12:08 AM
J
make sure you’re installing your deps into your studio packages and not global or frontend packages, the same with your vercel config, and like my screenshot above make sure that the vercel build is pointed at your studio directory if this is nested within a larger project repo or actual monorepo
Feb 12, 2022, 12:14 AM
J
here is the repo I just used to deploy if you’d like to compare: https://github.com/User/medium20
Feb 12, 2022, 12:16 AM
N
user U
Adding the Sanity CLI to package.json did the job.. it also took me like 2 minutes to deploy is that normal?Feb 12, 2022, 12:17 AM
J
for the hobby vercel plan I assume I’m going to be in queue behind their premium clients and have sometimes had to wait a few minutes - that doesn’t seem too bad.
Feb 12, 2022, 12:24 AM
N
Ah that’s why its working now perfectly thanks!
Feb 12, 2022, 12:25 AM
J
You’ll only need to rebuild when you make studio or schema changes, and as document changes are coming from the sanity content cloud just like in your dev env these should be nearly as fast as each other.
Feb 12, 2022, 12:26 AM
N
I also see that you can connect a custom domain and path for the studio and Next JS website which is really nice!
Feb 12, 2022, 12:27 AM
J
for the hobby vercel plan I assume I’m going to be in queue behind their premium clients and have sometimes had to wait a few minutes - that doesn’t seem too bad.
Feb 12, 2022, 12:24 AM
N
Ah that’s why its working now perfectly thanks!
Feb 12, 2022, 12:25 AM
J
You’ll only need to rebuild when you make studio or schema changes, and as document changes are coming from the sanity content cloud just like in your dev env these should be nearly as fast as each other.
Feb 12, 2022, 12:26 AM
D
user U
this was very helpful for me as well. For some unknown reason, Sanity was deploying just fine on Vercel up until 2 days ago (2/22/22) whereupon every push would fail. I tried many things, and what solved it for me was running sanity buildand then pushing that (while also ensuring Vercel had the default output set to
dist.
Feb 23, 2022, 11:51 PM
J
oh that’s annoying. I deployed a studio build for a friend to vercel a few days ago and left automatic CICD from the repo on github running. We’ve been tinkering with it the last couple of days without problems. There are many moving parts, and while vercel is a partner - things can easily change and break. Please let us know with a new thread here in help if you have further issues. Thank you!
Feb 24, 2022, 12:29 AM
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.