Getting Started
Installing the template
This project uses pnpm as package manager. To install pnpm globally, run the following command:
npm install -g pnpm1. Install Sanity CLI globally
pnpm install --global sanity@latestLogin to Sanity CLI:
sanity login2. Clone the repository
Run the command in your Terminal to clone the repository:
git clone https://github.com/serge-0v/sanityblocks.gitNote this is a private repo, to get access you need to buy the Sanity CMS addon from Shadcnblocks
2. Install dependencies
cd sanityblockspnpm installThis 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.exampleto.env.localfor both/frontendand/studiofolders - Add a new API token with read access (Viewer) and copy the token to
.env.localasSANITY_API_READ_TOKENfor/frontend - Copy the project ID and paste it to
.env.localasNEXT_PUBLIC_SANITY_PROJECT_IDfor/frontendandSANITY_STUDIO_PROJECT_IDfor/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.localfile for/frontend
5. Run the template locally
Start the development servers:
pnpm devThis 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