This starter is a statically generated site that uses [Next.js][nextjs] for the frontend and [Sanity][sanity-homepage] to handle its content. It comes with a native Sanity Studio that offers features like real-time collaboration, instant side-by-side content previews, and intuitive editing.
The Studio connects to Sanity Content Lake, which gives you hosted content APIs with a flexible query language, on-demand image transformations, powerful patching, and more. You can use this starter to kick-start a clean slate site or learn these technologies.
Note
This starter uses the
/pages
directory for Next.js routing.The template will be migrated to the currently experimental [/app][app-dir] directory when Vercel announce that it is production ready.
Example Studio with preview |
---|
File(s) | Description |
---|---|
sanity.config.ts |
Config file for Sanity Studio |
sanity.cli.ts |
Config file for Sanity CLI |
/pages/index.tsx |
Landing page for / . |
/pages/studio/[[...index]].tsx |
Where Sanity Studio is mounted |
/pages/api/draft.ts |
Serverless route for triggering Draft mode |
/sanity/schemas.ts |
Where Sanity Studio gets its content types from |
/sanity/env.ts |
Configuration for the Sanity project and dataset |
/sanity/schemas.ts |
Where Sanity Studio gets its content types from |
/sanity/lib/client.ts |
Sanity client configured based on env.ts |
/sanity/lib/image.ts |
Sanity image builder - unused in this template, but is needed to render Sanity images |
tailwind.config.js |
Tailwind config. Only applies to files listed under content |
All pages are wrapped in pages/_document.tsx
and pages/_app.tsx
.
Using the git clone clone the repo or template
Once cloned, run the following command from the project's root directory:
npm install or yarn install
Once node modules is installed create a project on sanity manage here and navigate to the project that created and find the varaibles for env from there and get the project id from there and create a .env.local
at the root as shown below you can find the read token from the api tab in your sanity project setting
NEXT_PUBLIC_SANITY_PROJECT_ID=
NEXT_PUBLIC_SANITY_DATASET=production
NEXT_PUBLIC_SANITY_API_VERSION="2023-09-23"
SANITY_API_READ_TOKEN="your-new-token"
Once the env is created run the below command it will start the sanity cms and next js and storybook server simultaneously
yarn dev or npm run dev
once the server is started you need to go to the Link for cms and for next js frontend go to Link and for storybook Link
in the project directory find a file named as sanity.config.ts
and change the name and title of the project in defineConfig function replace it with yours
then move to the Link and go to Site settings
> Default meta data
there add the default site title and the name and favicon for the frontend
Do the necessary tailwind configurations and the typography configuarations add colors in an object like parent and its child color and also add the spacing in rem and font sizes adn colors like below
primary: {
DEFAULT: '#124734',
100: '#040E0A',
200: '#0B2B1F',
300: '#A0B5AE',
400: '#D0DAD6',
},
Add the Home page in sanity cms to make the template functional