Hi and welcome, Harry. I personally take the monorepo approach and I believe in most cases, Sanity does too. In fact, in
this article Knut links to a list of
monorepo pros and cons that you could consider.
To start off, you’ll need to have installed the CLI. If you haven’t already, run
npm i -g @sanity/cli
.
Here’s how I get set up. I create my project folder, then in it I add two folders:
sanity
and
web
. Call them what you wish. I go to the sanity folder and run
sanity init
, which creates a project. I usually choose the clean schema and then add in my own boilerplate, but you can choose whichever you think will best get you started. At this point, your Sanity project should be ready to go. You could run
sanity start
and start working in the Studio, but I would normally get the rest set up first.
In
web
you can set up however you choose. You’re planning to work with Next.js, so you can follow the steps (
create-next-app
or however you get started).
Once you’re set up, go to your project folder (containing
sanity
and
web
) and initialize your git repo. Make sure you have
.gitignore
files set up so you’re not committing node_modules and other ignorables. I’ll assume you’re deploying to GitHub but GitLab, BitBucket, or even a third-party repo should work, too.
I deploy all my studios to Sanity, which simply requires a
sanity deploy
command. Everything is committed to my GitHub repo but is accessible from
https://<name>.sanity.studio
.
For your front end, go to
vercel.com and choose New Project. Import the repo you created and committed to, and then when you get to the Import Project screen, select
web
(or whatever you called it). Vercel should automatically detect your framework and set your build settings.
If you run into any struggles, please post back here.