Getting Started
Installing the template
This project uses pnpm as package manager. To install pnpm globally, run the following command:
npm install -g pnpm
1. Install Sanity CLI globally
pnpm install --global sanity@latest
Login to Sanity CLI:
sanity login
2. Clone the repository
Run the command in your Terminal to clone the repository:
git clone https://github.com/serge-0v/sanityblocks.git
Note this is a private repo, to get access you need to buy the Sanity CMS addon from Shadcnblocks
2. Install dependencies
cd sanityblockspnpm install
This will install the dependencies for both /frontend
and /studio
folders.
3. Create a new Sanity project
- Navigate to Sanity and create a new project.
- Navigate to API and add CORS origins
http://localhost:3000
(for local development) - Copy
.env.example
to.env.local
for both/frontend
and/studio
folders - Add a new API token with read access (Viewer) and copy the token to
.env.local
asSANITY_API_READ_TOKEN
for/frontend
- Copy the project ID and paste it to
.env.local
asNEXT_PUBLIC_SANITY_PROJECT_ID
for/frontend
andSANITY_STUDIO_PROJECT_ID
for/studio
4. Configuring Resend
To use the contact form, you need to configure Resend.
- Create a new Resend account
- Create a new API key
- Add new domain to the domains
- Set the API key and email address to send and receive form submissions in the
.env.local
file for/frontend
5. Run the template locally
Start the development servers:
pnpm dev
This will start the development servers for both /frontend
and /studio
folders.
6. Open the app and sign in to the Studio
- Open the Next.js app at http://localhost:3000 (The page will be empty until we import the data)
- Open the Studio running locally in your browser on http://localhost:3333/studio. You should now see a screen prompting you to log in to the Studio. Use the same service (Google, GitHub, or email) that you used when you logged in to the CLI.
7. Import Sample Data
Import the demo dataset to get started with sample content. Be careful with the --replace
flag, it will replace all the existing data in the dataset. This is a good way to get started with the template. You can always delete the dataset and start over. This will make your site look like the demo site: Demo.
cd studiosanity dataset import sample-data.tar.gz production --replace