Giter Site home page Giter Site logo

sanity-io / sanity-template-nextjs-clean Goto Github PK

View Code? Open in Web Editor NEW
140.0 14.0 59.0 1.64 MB

A clean Next.js template with a native authoring experience

Home Page: https://template-nextjs-clean.sanity.build

TypeScript 71.91% JavaScript 0.51% CSS 27.58%
team-ecosystem

sanity-template-nextjs-clean's Introduction

A minimal Next.js site with Sanity Studio

This starter is a statically generated site that uses Next.js for the frontend and Sanity 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.

Deploy with Vercel

Note

This starter uses the /pages directory for Next.js routing.

The template will be migrated to the currently experimental /app directory when Vercel announce that it is production ready.

Table of Contents

Project Overview

Example Studio with preview
Sanity Studio

Important files and folders

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.

Configuration

Step 1. Set up the environment

Use the Deploy Button below. It will let you deploy the starter using Vercel as well as connect it to your Sanity Content Lake using the Sanity Vercel Integration.

Deploy with Vercel

Step 2. Set up the project locally

Clone the repository that was created for you on your GitHub account. Once cloned, run the following command from the project's root directory:

npx vercel link

Download the environment variables needed to connect Next.js and the Studio to your Sanity project:

npx vercel env pull

This will create a git-ignored .env file with environment variables that will be used for local development.

Step 3. Run Next.js locally in development mode

npm install && npm run dev

When you run this development server, the changes you make in your frontend and studio configuration will be applied live using hot reloading.

Your blog should be up and running on http://localhost:3000! You can create and edit content on http://localhost:3000/studio.

Step 4. Deploy to production

To deploy your changes to production you use git:

git add .
git commit
git push

Alternatively, you can deploy without a git hosting provider using the Vercel CLI:

npx vercel --prod

Questions and Answers

It doesn't work! Where can I get help?

In case of any issues or questions, you can post:

How can I remove the "Next steps" block from my app?

You can remove it by deleting intro-template, and removing IntroTemplate usage from pages/index.tsx

Next steps

sanity-template-nextjs-clean's People

Contributors

ecospark[bot] avatar evavic44 avatar github-actions[bot] avatar renovate[bot] avatar snorrees avatar stipsan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sanity-template-nextjs-clean's Issues

App dir

Now that app dir is out of beta, are there any plans to update this template? Thanks!

app directory is missing

I see this repo hasn't been updated in 4 months. I trying to learn Sanity, like to know some of the basics before go any further with it. Unfortunately, the YT tutorials are already out of date unless I set the API for the date of tutorials.

sanity deploy command error

Hi, I tried to run sanity deploy but have this error

Error: [vite]: Rollup failed to resolve import "~/lib/sanity.api" from "D:/Projects/renz.dev/reminder/sanity.config.ts".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
build.rollupOptions.external

Stuck on the new project - vercel configuration

Hi,

I'm trying to use the link "deploy" from the guide on the read.me page of this repo. Unfortunately, I'm stuck at adding integrations where I think there is something wrong with Sanity. I've been trying several times and I'm able to create a repo on github and create a project in sanity, but it doesn't go past the following:

image image image

Also, I can see that it creates an instance in vercel.

Is there anything I've to do extra to have this set up?

How to run sanity deploy?

I want to deploy the studio to its own url, but
there is no deploy in the package.json

"scripts": {
    "build": "next build",
    "dev": "next",
    "format": "npx prettier --write . --ignore-path .gitignore",
    "lint": "next lint -- --ignore-path .gitignore",
    "lint:fix": "npm run format && npm run lint -- --fix",
    "start": "next start",
    "type-check": "tsc --noEmit"
  },

If I run sanity deploy in the root folder
I get an error

Error: [vite]: Rollup failed to resolve import "~/lib/sanity.api" from "/folder".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`

What's the way to do that with this setup?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.


Using a curated preset maintained by


Sanity: The Composable Content Cloud

Warning

These dependencies are deprecated:

Datasource Name Replacement PR?
github-actions tibdex/github-app-token Available

Pending Approval

These branches will be created by Renovate only once you click their checkbox below.

  • chore(deps): update non-major (@portabletext/react, @sanity/client, @sanity/vision, @tailwindcss/typography, @types/react, autoprefixer, eslint, eslint-config-next, peter-evans/create-pull-request, postcss, prettier, prettier-plugin-packagejson, prettier-plugin-tailwindcss, react, react-dom, sanity, styled-components, tailwindcss, tibdex/github-app-token, typescript)
  • chore(deps): update actions/cache action to v4
  • chore(deps): update dependency @sanity/demo to v2
  • chore(deps): update dependency eslint-plugin-simple-import-sort to v12
  • chore(deps): update dependency next-sanity to v8
  • chore(deps): update dependency next-sanity to v9
  • chore(deps): lock file maintenance
  • ๐Ÿ” Create all pending approval PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • actions/checkout v4
  • actions/setup-node v4
.github/workflows/lock.yml
  • dessant/lock-threads v5@1bf7ec25051fe7c00bdd17e6a7cf3d7bfb7dc771
.github/workflows/prettier.yml
  • actions/checkout v4
  • actions/setup-node v4
  • actions/cache v3
  • tibdex/github-app-token v2@3beb63f4bd073e61482598c45c71c1019b59b73a
  • peter-evans/create-pull-request v6@b1ddad2c994a25fbc81a28b3ec0e368bb2021c50
npm
package.json
  • @portabletext/react 3.0.11
  • @sanity/client 6.12.3
  • @sanity/demo 1.0.2
  • @sanity/vision 3.28.0
  • @tailwindcss/typography 0.5.10
  • next 14.1.0
  • next-sanity 5.5.11
  • react 18.2.0
  • react-dom 18.2.0
  • sanity 3.28.0
  • sanity-plugin-iframe-pane 2.6.1
  • styled-components 6.1.8
  • @types/react 18.2.55
  • autoprefixer 10.4.17
  • eslint 8.56.0
  • eslint-config-next 14.1.0
  • eslint-plugin-simple-import-sort 10.0.0
  • postcss 8.4.35
  • prettier 3.2.5
  • prettier-plugin-packagejson 2.4.10
  • prettier-plugin-tailwindcss 0.5.11
  • tailwindcss 3.4.1
  • typescript 5.3.3
  • node >=16

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.