Skip to content

sanity-io/sanity-template-astro-clean

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clean Astro + Sanity app

This template includes an Astro app with a Sanity Studio – an open-source React application that connects to your Sanity project’s hosted dataset. The Studio is configured locally and can then be deployed for content collaboration.

Features

Demo

https://template-astro-clean.sanity.build

Getting Started

Install the template

1. Initialize template with Sanity CLI

Run the command in your Terminal to initialize this template on your local computer.

See the documentation if you are having issues with the CLI.

npm create sanity@latest -- --template sanity-io/sanity-template-astro-clean

2. Run Studio and Astro app locally

Navigate to the template directory using cd <your app name>, and start the development servers by running the following command

npm run dev

3. Open the app and sign in to the Studio

Open the Astro app running locally in your browser on http://localhost:4321.

Open the Studio running locally in your browser on http://localhost:3333. 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.

Adding content with Sanity

1. Publish your first document

The template comes pre-defined with a schema containing a Post document type.

From the Studio, click "+ Create" and select the Post document type. Go ahead and create and publish the document.

Your content should now appear in your Astro app (http://localhost:4321)

2. Extending the Sanity schema

The schema for the Post document type is defined in the studio/src/schemaTypes/post.ts file. You can add more document types to the schema to suit your needs.

Deploying your application and inviting editors

1. Deploy Sanity Studio

Your Astro frontend (/astro-app) and Sanity Studio (/studio) are still only running on your local computer.

Back in your Studio directory (/studio), run the following command to deploy your Sanity Studio.

npx sanity deploy

2. Deploy Astro app to Vercel

You have the freedom to deploy your Astro app to your hosting provider of choice. With Vercel and GitHub being a popular choice, we'll cover the basics of that approach.

  1. Create a GitHub repository from this project. Learn more.
  2. Create a new Vercel project and connect it to your Github repository.
  3. Set the Root Directory to your Astro app.
  4. Configure your Environment Variables.

3. Invite a collaborator

Now that you’ve deployed your Astro application and Sanity Studio, you can optionally invite a collaborator to your Studio. Open up Manage, select your project and click "Invite project members"

They will be able to access the deployed Studio, where you can collaborate together on creating content.

Resources