nextjs + sanity studio v3 = 💖

Overview

Sanity.io and Next.js

[main image placeholder]

Sanity.io is the platform for structured content. With Sanity.io you can use the open-source, single page application to manage your text, images, and other media with APIs. More! You can also use it to quickly set up an editing environment that you can customize.

Want to try Sanity.io with Next.js? This blog starter uses Next.js and Sanity which generates both the front-end and content editor so that you can jump immediately into action. The Sanity editor is React (with Typescript) which you can access by adding /studio to the url. It comes with real-time collaboration and instant "as-you-type" previews. Further down, you'll be shown how to configure ISR (incremental static rebuilding) for performant sites that can rebuild instantly.

You'll get:

Demo

Blog Studio
[blog image placeholder] [studio image placeholder]

Configuration

Step 1. Set up the environment

Use the Deploy Button below, you'll deploy the example using Vercel as well as connect it to your Sanity dataset using the Sanity Vercel Integration.

Deploy with Vercel

Step 2. Set up the project locally

Clone the repository that was created for you. Once cloned, from the project's root directory, link it to Vercel:

npx vercel link

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

npx vercel env pull
You can also set up manually

If using the integration isn't an option. Or maybe you want to work locally first and deploy to Vercel later. Whatever the reason this guide shows you how to setup manually.

Bootstrap the example

Execute create-next-app with npm, Yarn, or pnpm:

npx create-next-app --example https://github.com/sanity-io/vercel-next.js-examples-cms-sanity-studio-v3
yarn create next-app --example https://github.com/sanity-io/vercel-next.js-examples-cms-sanity-studio-v3
pnpm create next-app --example https://github.com/sanity-io/vercel-next.js-examples-cms-sanity-studio-v3

Set up environment variables

Create a new Sanity project and at the end note the values for --project and --dataset:

Screenshot of a screen with a terminal command containing "--project ygjibjo8 --dataset production"

In the above screenshot the projectId is ygjibjo8 and dataset is production.

Copy the .env.local.example file in this directory to .env.local (which will be ignored by Git):

cp .env.local.example .env.local

Then set these variables in .env.local:

  • NEXT_PUBLIC_SANITY_PROJECT_ID should be the projectId.
  • NEXT_PUBLIC_SANITY_DATASET should be the dataset.
  • SANITY_API_READ_TOKEN create an API token with read-only permissions:
    • Go to https://manage.sanity.io/ and open your project.
    • Go to API and the Tokens section at the bottom, launch its Add API token button.
    • Name it SANITY_API_READ_TOKEN, set Permissions to Viewer.
    • Hit Save and you can copy/paste the token.

Your .env.local file should look like this:

NEXT_PUBLIC_SANITY_PROJECT_ID=...
NEXT_PUBLIC_SANITY_DATASET=...
SANITY_API_READ_TOKEN=...

Import to Vercel

To deploy your local project to Vercel, push it to GitHub/GitLab/Bitbucket and import to Vercel. Important: When you import your project on Vercel, make sure to click on Environment Variables and set them to match your .env.local file. After it's deployed link your local code to the Vercel project:

npx vercel link

Step 3. Run Next.js locally in development mode

npm install && npm run dev
yarn install && yarn dev

When working locally you can make changes to your blog and studio, and your changes are applied live using hot reloading.

Your blog should be up and running on http://localhost:3000! You'll be able to find the studio in http://localhost:3000/studio.

In case of any issues, you can post on GitHub discussions.

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

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

You can remove it by deleting the IntroTemplate component in /pages/index.tsx.

Next steps

Comments
  • Bug: on-demand revalidation showing one step old stale data

    Bug: on-demand revalidation showing one step old stale data

    I'm using the api/revalidate to update content. But each time it updates, it returns one step old data. Not fresh.

    I'm tried using bothuseCdn: true & false, but same result. Here, the webhook fires immediately after publishing, but apicdn takes upto 60 sec to update the content. Thus Next.js getting old data each time.

    See below video.

    Video transcription:

    Starts next production builds change “first post” to “Our first post” Simulate “webhook” requests Data do not change

    [next attempt] change “Our first post” to “Next first post” Data change to Stale “Our First post” this time but new data is “Next First Post” (edited)

    https://user-images.githubusercontent.com/1884712/207079785-48b821f7-1da7-439b-a07c-665fcdbe3689.mp4

    opened by surjithctly 9
  • Unhandled Runtime Error while previewing blog post

    Unhandled Runtime Error while previewing blog post

    I ran into the following error while previewing posts inside Sanity:

    Unhandled Runtime Error
    Error: object is not a function
    
    Call Stack
    String
    <anonymous>
    eval
    webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react/cjs/react.shared-subset.development.js (135:28)
    Array.map
    <anonymous>
    printWarning
    webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react/cjs/react.shared-subset.development.js (134:43)
    error
    webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react/cjs/react.shared-subset.development.js (118:21)
    lazyInitializer
    webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react/cjs/react.shared-subset.development.js (1161:25)
    attemptResolveElement
    webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js (1250:59)
    resolveModelToJSON
    webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js (1660:53)
    Object.toJSON
    webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js (1121:40)
    stringify
    <anonymous>
    processModelChunk
    webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js (172:36)
    retryTask
    webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js (1868:50)
    performWork
    webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js (1906:33)
    eval
    webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js (1297:40)
    scheduleWork
    webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js (52:25)
    pingTask
    webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js (1296:29)
    ping
    webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js (1309:40)
    runMicrotasks
    <anonymous>
    processTicksAndRejections
    node:internal/process/task_queues (96:5)
    

    https://user-images.githubusercontent.com/57044804/203906563-1094b61c-7102-473c-92fe-768390108a34.mp4

    This issue occurs while the post is published and unpolished. SANITY_API_READ_TOKEN has been added.

    Any thoughts on what I'm missing/how I could further debug this issue? 🙏

    bug 
    opened by laurosilvacom 4
  • feat: implement `appDir`

    feat: implement `appDir`

    Preview Deploy link

    ~~Blocked by:~~

    • ~~All Document/HTML requests are always missing cache, verify by looking at x-vercel-cache which is MISS but should be HIT like it is on the main.~~
    • ~~When in production (next build && next start) and SANITY_REVALIDATE_SECRET isn't set, an error is thrown when trying to view a post:~~
      Error: invariant: invalid Cache-Control duration provided: 0 < 1
      
    • ~~When running locally (next dev) the post pages throw this error:~~
      Error: Dynamic server usage: previewData
      

    previewData blockers worked around, revisit in https://github.com/sanity-io/nextjs-blog-cms-sanity-v3/issues/95 once Next 13 is shipping an updated previewData() mechanic.

    opened by stipsan 4
  • feat/add-intro-template

    feat/add-intro-template

    Link to figma: https://www.figma.com/file/C77wPdW97bGo7Of1vMAc80/V3-Starters-%E2%80%93-Prototypes?node-id=64%3A1094

    Test that all the links that they go to the correct places

    opened by ninaandal 4
  • fix(deps): update dependency next-sanity to v3

    fix(deps): update dependency next-sanity to v3

    Mend Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | next-sanity | ^2.1.0 -> ^3.0.0 | age | adoption | passing | confidence |


    Release Notes

    sanity-io/next-sanity

    v3.0.0

    Compare Source

    ⚠ BREAKING CHANGES
    Features

    Configuration

    📅 Schedule: Branch creation - "before 2am" (UTC), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate using a preset from Sanity. View repository job log here

    dependencies major 
    opened by renovate[bot] 3
  • Revalidate webhook config link not working

    Revalidate webhook config link not working

    I tried using the shared config link for the revalidate webhook and ran into an internal server error until removing the dash from the webhook name. Not sure if sanity is suppose to allow dashes in webhook names, but may want to remove the dash in the config url (eg. name=On+demand+Revalidation).

    bug 
    opened by stephenarra 3
  • fix(deps): update dependencies (non-major)

    fix(deps): update dependencies (non-major)

    Mend Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | @sanity/vision (source) | ^3.0.6 -> ^3.1.2 | age | adoption | passing | confidence | | next (source) | ^13.0.7 -> ^13.1.0 | age | adoption | passing | confidence | | next-sanity | ^3.1.5 -> ^3.1.8 | age | adoption | passing | confidence | | sanity (source) | ^3.0.6 -> ^3.1.2 | age | adoption | passing | confidence |


    Release Notes

    sanity-io/sanity

    v3.1.2

    Compare Source

    Installation and upgrading

    To initiate a new Studio without installing the CLI globally:

    npx create-sanity@latest
    

    To upgrade a v3 Studio:

    npm install sanity@latest
    

    🐛 Notable bugfixes

    • Fixed a regression with release 3.1.0 where a custom style in the portable text input would not fallback to be rendered as the normal style when a rendering-component for that style was not defined.

    📓 Full changelog

    Author | Message | Commit ------------ | ------------- | ------------- Per-Kristian Nordnes | fix(core/form): fix forgotten optional extension | 24805ae Per-Kristian Nordnes | fix(form/inputs): fix component fallback behaviour | e892c62 Per-Kristian Nordnes | fix(schema): fix validator text typo | 5e4c562

    v3.1.1

    Compare Source

    Installation and upgrading

    To initiate a new Studio without installing the CLI globally:

    npx create-sanity@latest
    

    To upgrade a v3 Studio:

    npm install sanity@latest
    

    🐛 Notable bugfixes

    • Fixes an issue where createAuthStore would incorrectly require a client factory to be passed
    • Fixes an issue where lodash was not optimized in all released Sanity packages
    • Fixes an issue where disabling direct uploads when using multiple asset sources would not work

    📓 Full changelog

    Author | Message | Commit ------------ | ------------- | ------------- Cody Olsen | fix: ensure lodash is optimized in every monorepo package | 8494ac0 Cody Olsen | fix: apply config.form.image.directUploads | cf52ee7 Marius Lundgård | fix: clientFactory should be optional | d894d56 Espen Hovlandsdal | chore: temporarily skip flakey tests | b8534b1 Espen Hovlandsdal | chore: update release notes script with new instructions | afcc2f5 Espen Hovlandsdal | fix(groq): provide tsdoc for groq template literal function | f9520b2

    v3.1.0

    Compare Source

    Installation and upgrading

    To initiate a new Studio without installing the CLI globally:

    npx create-sanity@latest
    

    To upgrade a v3 Studio:

    npm install sanity@latest
    

    ✨ Highlights

    Improved customization and TypeScript support for the Portable Text Input and schemas

    Improved support for custom rendering of the content in the Portable Text input via .components.block, component.inlineBlock and .components.annotation render callbacks for object-like schema types, references and type aliases.

    While this has been possible previously by modifying the block schema locally, these customizations can now also be put directly on the various content types themselves, to be shared between different Portable Text inputs using them. For example you can now customize how an author reference would appear in various Portable Text contexts on the author schema itself.

    Also text specific schema properties like decorators, styles and lists for the block type itself have slighly changed their configuration in order to better align with the rest of the studio. More info: Changes in block schema customization properties.

    If you previously did customization of the editor using your own render callbacks or icons through the .blockEditor property in the block schema, you will get a deprecation warning, but they will still continue to work until further notice.

    Please refer to the documentation for how to customize the block type and the Portable Text editor for v3 of the studio.

    Besides this, the Portable Text input related code and schema types have been given a TypeScript update for better type safety and developer experience.

    Studio appearance

    The user menu now has options to select the appearance (color scheme) of the Studio. The selected appearance is stored in local storage and is reused on the next visit.

    Screenshot of user menu with appearance options

    Logo component updates

    The button in the navbar that wraps the custom logo component has no padding anymore. This update is made in order to give the custom logo component full control over how big the button in the navbar should be. Therefore, the custom logo component may need to be updated in order to achieve the previous look. Below is an example of how to recreate the same result as before:

    import {defineConfig} from 'sanity'
    import {Box} from '@&#8203;sanity/ui'
    
    function MyLogo() {
      return (
        <Box padding={3}> // <-- Wrap your custom logo with a `Box` with `padding={3}`
          <CustomLogo />
        </Box>
      )
    }
    
    export default defineConfig({
      // ... rest of config
    
      studio: {
        components: {
          logo: MyLogo,
        },
      },
    })
    

    🐛 Notable bugfixes

    • This update fixes so that the component in the root config (ie in defineConfig) is the component that receives the result of the props passed on with renderDefault in previous custom components.
    • Fixed an issue with custom sort orders

    📓 Full changelog

    Author | Message | Commit ------------ | ------------- | ------------- Bjørge Næss | fix(form): fix issue with zero being rendered as empty string in number input | 7be7511 Marius Lundgård | build: add bin directory to distribution | a1f6e00 Herman Wikner | feat(core): update user menu with color schemes | 788d23b Herman Wikner | feat(core): store selected color scheme i local storage | 9ce0108 Herman Wikner | fix(core): update workspace preview design | 543a0f3 Marius Lundgård | fix(config): respect unstable_clientFactory | bcd4854 Cody Olsen | fix: optimize lodash imports (#​3974) | 6c7d48d Marius Lundgård | docs: update readme (#​3987) | 88c90eb Marius Lundgård | docs: remove ToC | 13389f5 Bjørge Næss | chore(form): replace react-sortable-hoc with dndkit (#​3961) | 551c4d5 Espen Hovlandsdal | fix(cli): only require workspace name if more than 1 workspace | 743244b Espen Hovlandsdal | feat(core): add userHasRole utility method | cd0819f Snorre Eskeland Brekke | fix(block-tools): ignore blocks inside list items (#​3492) | 5e51831 Espen Hovlandsdal | feat(core): add new documentIdEquals utility method | f7eb4b3 Espen Hovlandsdal | chore(vision): use react 18 compatible dependencies | 401f08a Espen Hovlandsdal | fix(config): throw error early if tools/template resolution fails | 2f2e467 Herman Wikner | fix(core): components API execution order | 299ac06 vicbergquist | fix(desk): always use default ordering on first rendering if any and update order on sort | 663cc67 Espen Hovlandsdal | refactor(desk): remove unused default ordering option in useDocumentList | e2209ec Espen Hovlandsdal | fix(desk): recompute default sort order on desk structure change | 4f9a353 Espen Hovlandsdal | fix(desk): use last updated at as default sort order | d5166e5 Per-Kristian Nordnes | refactor(types): refactor Block schemas for new component extension api | dfd33ce Per-Kristian Nordnes | refactor(types): refactor portable text types used internally in the studio | 48c03a9 Per-Kristian Nordnes | refactor(types): remove deprecated block validator Rules from v2 | 7aa1404 Per-Kristian Nordnes | refactor(schema): allow for .components in block schema + ensure that the result has a name | 5b5e878 Per-Kristian Nordnes | refactor(validation): remove deprecated block validation rule. Should be using 'Rule.custom' in v3. | 5f92213 Per-Kristian Nordnes | refactor(validation): update pt types | acc0e79 Per-Kristian Nordnes | refactor(core/form): add block and annotation component schema extensions | bbd32ae Per-Kristian Nordnes | refactor(block-tools): use pt-types from @​sanity/types | 27d5133 Per-Kristian Nordnes | refactor(form/inputs): Custom rendering support via schema for PT-input | f1152f7 Per-Kristian Nordnes | refactor(core/fields/diffs): use new types in Portable-text-diffs | b2aa1f2 Per-Kristian Nordnes | refactor(core/preview): use new types in portable-text previews | 3fd22cc Per-Kristian Nordnes | refactor(core/form/inputs): function can now be moved out of scope | ccdc0fd Per-Kristian Nordnes | refactor(core/form/inputs): keep using schemaType var name | a65169b Per-Kristian Nordnes | refactor(core/form/input): use updated types for block schemas and pt render callbacks | aa3ee4e Per-Kristian Nordnes | refactor(types/schema): support seperate inlineBlock render callback | c21a8f1 Per-Kristian Nordnes | refactor(schema): validate lists and new component for block type | afd01e2 Per-Kristian Nordnes | refactor(types): limit supported types in block types .of to objects and refs | cb867b8 Per-Kristian Nordnes | refactor(core/form): update render callback support for block types | 0902fa5 Per-Kristian Nordnes | chore: mark types required (by schemas) as @​beta | edb3bd0 Per-Kristian Nordnes | refactor(portable-text-editor): update types and add render callbacks to the PTE | 6202a8c Per-Kristian Nordnes | chore: update puppeteer to latest version | a9dc1ea Per-Kristian Nordnes | test(portable-text-editor): update tests | 05abec0 Per-Kristian Nordnes | chore: update yarn.lock | 0590a81 Per-Kristian Nordnes | chore(portable-text-editor): mark types with availablility status | 3408962 Per-Kristian Nordnes | refactor(portable-text-editor): simplify code | 8c08f85 Per-Kristian Nordnes | refactor(portable-text-editor): rename type > schemaType | d25cbb5 Per-Kristian Nordnes | refactor(portable-text-editor): rename type > schemaType | b18716f Per-Kristian Nordnes | feature(schema): backward compatibility for breaking changes in block schema | c323b12 Bjørge Næss | fix(schema): add help id to blockeditor schema warnings | 8d74ace Herman Wikner | feat(core): move padding from LogoButton to StudioLogo | d774bc6 Herman Wikner | dev(test-studio): update custom logo component | bb61fa1 Marius Lundgård | fix: pass readOnly to select element (#​3900) | f70736f

    vercel/next.js

    v13.1.0

    Compare Source

    Core Changes
    • Fix windows slashes for app client entry: #​44052
    • Hash both pitch and main loader for server CSS imports: #​44063
    • Add tracing for testing tools: #​44046
    • Run packing in tests in parallel: #​44048
    • feat: app dir error-global component: #​44066
    • Fix ignoring dev warning for preload component: #​44065
    • refactor(next-swc): introduce next-binding to consolidate dependencies.: #​43473
    • Add lodash to server components external packages: #​44022
    • Fix dev session stopped handling: #​44112
    • Add jsdoc/no-types eslint rule for TypeScript files: #​44049
    • Revert "Remove useState from next/image (#​43587)": #​44094
    • should not contain pages css in app dir: #​44151
    • Upgrade undici to 5.14.0 to fix fetch redirect bug: #​44133
    • build(cargo): fix turbopack + next-swc build: #​43983
    • Align onRecoverableError callback between pages and app dir: #​44161
    • build(cargo): update turbopack: #​44167
    • Update styled-jsx: #​44070
    • Fix crash in GraalVM: #​44176
    • Also check error.message as digest for recoverable errors in pages: #​44185
    • Move options to stable: #​44195
    • Move transpilePackages out of experimental: #​44194
    • Fix CSS resources being duplicated in app dir: #​44168
    • Add telemetry for stable features: #​44201
    • Add warning for experimental flags that have moved: #​44202
    • build(cargo): bump up turbopack: #​44206
    • Bump @vercel/[email protected]: #​44193
    • Disable Image Optimization API when next.config.js has unoptimized: true: #​44205
    • Honour distDir in type generation: #​44207
    • Only once for the next/head usage in app dir: #​44233
    • Enable allowMiddlewareResponseBody by default: #​44224
    • Move modularizeImports out of experimental: #​44240
    • Update config validation for latest turbopack changes: #​44223
    • build(cargo): update turbopack: #​44241
    • update turbopack for bugfixes: #​44251
    Documentation Changes
    • docs: Add explanation about font-display: #​44001
    • Test that adding query can be detected by useSearchParams: #​43969
    • Add static test for useSelectedLayoutSegments: #​43955
    • Docs: Update deployment.md with Firebase, Amplify and Cloudflare: #​44092
    • Add test for rewriting in middleware in app-dir: #​43971
    • docs: Add missing type to import statement: #​44111
    • docs: update next/dynamic docs: #​44067
    • Update disabling-http-keep-alive.md for server-side only: #​43374
    • docs: fix spelling error: #​44191
    • Write tests for navigation between app-dir and pages: #​43881
    • Add docs for middleware flags: #​44235
    Example Changes
    • Updates with-supertokens example: #​44042
    • Fix styled-components setup in turbo example: #​44165
    • update with-turbopack example for postcss/tailwind support: #​44261
    Misc Changes
    • Run packing in tests in parallel
    • Revert "Run packing in tests in parallel"
    • Remove extra turbo test: #​44073
    • Implement new core test API: #​44086
    • Refactor more tests to createNextDescribe: #​44104
    • Add types as a default dependency into tests: #​44140
    • Suggest contributors to use shallow clone: #​44158
    • Update pnpm new-test to use createNextDescribe: #​44147
    • Update README templates to include snippet on next/font: #​44088
    • Wrap CSS variable in var: #​44153
    • Ensure next.url is used instead of next.appPort: #​44163
    • test: add test for notFound during streaming: #​44078
    • Fix test template example: #​44170
    • Remove devcontainer network host argument: #​44157
    • Fix pnpm install on Azure: #​44179
    • Enable ReactRefreshLogBox scss test: #​44180
    • Increase recommended git clone depth: #​44181
    • Document how chain works in BrowserInterface and chain to browser.eval: #​44085
    • Remove browser.refresh in app tests: #​44186
    • Move tests into their test folder: #​44183
    • Add test checking that repeated edits won't cause hydration issues: #​44189
    • Update labeler.json with current next.js team members: #​44231
    Credits

    Huge thanks to @​shuding, @​hanneslund, @​rishabhpoddar, @​JanKaifer, @​huozhi, @​timneutkens, @​kwonoj, @​IamManchanda, @​styfle, @​nyedidikeke, @​jaslong, @​jueungrace, @​longzheng, @​akshitsinha, @​Brooooooklyn, @​gish, and @​sokra for helping!

    sanity-io/next-sanity

    v3.1.8

    Compare Source

    Bug Fixes

    v3.1.7

    Compare Source

    Bug Fixes

    v3.1.6

    Compare Source

    Bug Fixes

    Configuration

    📅 Schedule: Branch creation - "before 2am" (UTC), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate using a preset from Sanity. View repository job log here

    dependencies bump 
    opened by renovate[bot] 2
  • chore: return null from alert banner if no preview

    chore: return null from alert banner if no preview

    This was giving me a type error of

    'AlertBanner' cannot be used as a JSX component.
      Its return type 'Element | undefined' is not a valid JSX element.
        Type 'undefined' is not assignable to type 'Element | null'.ts(2786)
    

    The solution is to either return null or return <></>

    opened by JamesSingleton 2
  • fix(deps): update dependency sanity to v3.0.0

    fix(deps): update dependency sanity to v3.0.0

    Mend Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | sanity (source) | 3.0.0-rc.3 -> 3.0.0 | age | adoption | passing | confidence |


    Release Notes

    sanity-io/sanity

    v3.0.0

    Compare Source

    v3.0.0-v3-v2-pte.56

    Compare Source

    v3.0.0-v3-pte.87

    Compare Source

    v3.0.0-v3-pte.80

    Compare Source

    v3.0.0-v3-pte.79

    Compare Source

    v3.0.0-v3-pte.69

    Compare Source

    v3.0.0-v3-pte.61

    Compare Source

    v3.0.0-v3-pte.59

    Compare Source

    v3.0.0-v3-pte.58

    Compare Source

    v3.0.0-v3-pte.57

    Compare Source

    v3.0.0-v3-pte.56

    Compare Source

    v3.0.0-v3-pte.55

    Compare Source

    v3.0.0-v3-pte.49

    Compare Source

    v3.0.0-v3-pte.48

    Compare Source

    v3.0.0-v3-pte.33

    Compare Source

    v3.0.0-v3-pte.31

    Compare Source

    v3.0.0-v3-pte.30

    Compare Source

    v3.0.0-v3-pte.17

    Compare Source

    v3.0.0-v3-pte.16

    Compare Source

    v3.0.0-v3-pte.13

    Compare Source

    v3.0.0-v3-pte.12

    Compare Source

    v3.0.0-v3-pkg-utils.189

    Compare Source

    v3.0.0-v3-pkg-utils.79

    Compare Source

    v3.0.0-v3-pkg-utils.59

    Compare Source

    v3.0.0-v3-pkg-utils.54

    Compare Source

    v3.0.0-v3-pkg-utils.52

    Compare Source

    v3.0.0-v3-esm.54

    Compare Source

    v3.0.0-v3-esm.53

    Compare Source

    v3.0.0-v3-esm.52

    Compare Source

    v3.0.0-v2-v3-pte.21

    Compare Source

    v3.0.0-v2-v3-pte.20

    Compare Source

    v3.0.0-v2-v3-pte.19

    Compare Source

    v3.0.0-v2-v3-pte.18

    Compare Source

    v3.0.0-v2-v3-pte.17

    Compare Source


    Configuration

    📅 Schedule: Branch creation - "before 2am" (UTC), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate using a preset from Sanity. View repository job log here

    dependencies patch 
    opened by renovate[bot] 2
  • fix(deps): update dependency next-sanity to v3

    fix(deps): update dependency next-sanity to v3

    Mend Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | next-sanity | ^2.1.0 -> ^3.0.2 | age | adoption | passing | confidence |


    Configuration

    📅 Schedule: Branch creation - "before 2am" (UTC), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Renovate will not automatically rebase this PR, because other commits have been found.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate using a preset from Sanity. View repository job log here

    dependencies major 
    opened by renovate[bot] 2
  • Revalidate

    Revalidate "More stories" with a webhook doesn't always work when adding/removing a post

    Related Commit 9c45983a5e97c2621daae7251d0356f856594196 (https://nextjs-blog-cms-sanity-v3-m2zs0oidy.sanity.build).

    Originally posted by @kmelve in https://github.com/sanity-io/nextjs-blog-cms-sanity-v3/issues/89#issuecomment-1321304197

    Summary

    When updating a post or author, revalidation works as expected across the homepage and existing posts. However, when adding or removing/unpublishing a post entirely, sometimes only the homepage path gets revalidated. This means the "More stories" section on other exisiting posts doesn't get updated. The deleted/unpublished post also gets left behind and is still accessible.

    Sometimes it does work, I can't seem to figure out why.

    Video attached shows:

    • Newly deployed site using the deploy button in this repo (as at e43759b)
    • Site with 4 posts with a new 5th post being published, validation of home + all existing posts works (as seen in the function logs on the left)
    • When deleting that 5th post, only the homepage is invalidated, leaving the "More stories" section on all other posts out of date + the removed post still available
    • Adding another new post (Test Post 06), only the homepage gets revalidated, the new post is missing from "More Stories" on all other posts
    • Unpublishing an existing post (Test Post 04) only invalidates the homepage and itself, leaving it in the "More Stories" section on most other posts

    Expected behaviour:

    • Adding a new post should add it to the "More stories" section of all other posts.
      • Note that this does reliably happen for me when updating a post, making a new post and then updating it immediately after is my current workaround
    • Removing/Unpublishing a post should:
      • remove it from the "More stories" section of all other posts
      • make it inaccessible from the website as a whole.

    https://user-images.githubusercontent.com/36751136/203326802-a09fd61c-05d9-454b-9ed8-e9dcaf23bf5e.mp4

    opened by tddostu 2
  • chore(deps): lock file maintenance

    chore(deps): lock file maintenance

    Mend Renovate

    This PR contains the following updates:

    | Update | Change | |---|---| | lockFileMaintenance | All locks refreshed |

    🔧 This Pull Request updates lock files to use the latest dependency versions.


    Configuration

    📅 Schedule: Branch creation - "before 3am on the first day of the month" (UTC), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate using a preset from Sanity. View repository job log here

    dependencies lockFileMaintenance 
    opened by renovate[bot] 1
  • @sanity/ui Module parse failed.

    @sanity/ui Module parse failed.

    Steps to reproduce 1./ Follow steps 1 -> 3 as per README 3./ Visit studio `http://localhost:3000/studio 4./ Development server crashes with the following error.

    error - ./node_modules/@sanity/ui/dist/index.esm.js
    Module parse failed: 'import' and 'export' may appear only with 'sourceType: module' (61:0)
    You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
    | function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
    | function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
    > import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
    | import { useMemo, useState, useRef, useEffect, createContext, useContext, useLayoutEffect, forwardRef, useId, useCallback, cloneElement, isValidElement, createElement, Component, memo, useReducer, Children, Fragment as Fragment$1 } from 'react';
    | import ReactIs, { isElement as isElement$1, isFragment, isValidElementType } from 'react-is';
    ```
    
    This error occurs with Yarn, PNPM and NPM package managers.
    opened by bryanjhickey 2
  • Cannot find module '@sanity/ui'

    Cannot find module '@sanity/ui'

    Keep getting this when I try to go to the /studio Unhandled Runtime Error Error: Cannot find module '@sanity/ui'

    The loader shows for a sec and the this happens.

    The studio worked for a couple of hours and then this started to happen.

    I tried installing @sanity/ui and nothing.

    Does anyone have a hint on how to solve this?

    opened by enriqueiturriagaa 1
  • Error When Viewing Deployed Studio Project

    Error When Viewing Deployed Studio Project

    Expected Behavior:

    When I deploy the sanity project to the hosted Studio version, I should be able to access and use it at the set subdomain, i.e. your-project.sanity.studio.

    Actual Behavior:

    The Studio crashes with error:

    Uncaught error: process is not defined 
    ReferenceError: process is not defined
    

    Error references file /static/sanity.3279a857.js:4558:3169

    The studio does not crash locally or from blog domain /studio.

    Steps To Reproduce:

    1. Follow the steps to Configure locally and deploy from the README
    2. Ensure the values for the .env are referencing your Sanity project
    3. Deploy your project to Sanity via npx @sanity/cli@dev-preview deploy
      • This command must be used instead of sanity deploy with the current v3
      • Reference: https://github.com/sanity-io/sanity/discussions/3350#discussioncomment-2964672
    4. Log in to your Sanity.io account, select the deployed project and set a subdomain if one isn't already set
    5. Visit the configured subdomain for the studio
    6. Observe error: Uncaught error: process is not defined

    Context

    This template seems to be only configured for the self-hosted Studio at http://localhost:3000/studio or your domain /studio path.

    The sanity.config.ts file uses the node process object to access the env file. Since the Studio is a static client-side application, process is not available there and is therefore undefined.

    Sanity's v2 - v3 migration guide gives a work around for this by setting the appropriate values in your env file that will be bundled and exposed within import.meta.env. Theses variables must start with SANITY_STUDIO_ in the name.

    Possible Solution:

    We can accommodate both by conditionally using process.env.NEXT_PUBLIC_SANITY_PROJECT_ID or import.meta.env.SANITY_STUDIO_PROJECT_ID depending on if process.env is defined.

    This is a little tricky since we'll have to first check if window is not 'undefined' (referencing something like this), so on the client-side version we can set a process attribute that would allow us to check for it in the config file without causing errors.

    Within TypeScript will have to reference some interfaces for import.meta as well, within a env.d.ts file.

    I've got this working on my personal site.

    opened by MarioGiancini 3
  • Document what `renovate.json` is for

    Document what `renovate.json` is for

    Created a new project using this starter, and I find this renovate.json file in it, but I don't see any explanation of why it's here, what it's for, or how to use it.

    {
      "$schema": "https://docs.renovatebot.com/renovate-schema.json",
      "extends": [
        "github>sanity-io/renovate-presets//ecosystem/auto",
        "github>sanity-io/renovate-presets//ecosystem/studio-v3"
      ]
    }
    

    What does it do? Should it be deleted in my project? Or does it have value to me? If so, how? Do I need to set something up for it to "do anything"?

    docs 
    opened by Svish 5
  • Error when logging in locally: Not found - Session with sid ___ not found

    Error when logging in locally: Not found - Session with sid ___ not found

    I have set up and deployed the Sanity v3+next.js starter, pulled the created git-repo locally, and followed the configuration steps in the readme.

    After booting it up locally via npm run dev, I go to http://localhost:3000/studio and I get the Sanity login. Completing the login, I'm then presented with this error page:

    image

    If I then refresh the page, I seem to get into the studio fine. 🤷‍♂️

    bug 
    opened by Svish 5
Owner
Sanity
Sanity.io a platform for structured content that comes with an open source editor that you can customize with React.js.
Sanity
Student reviews for OMS courses. Built with NextJS and Typescript. Backed by Sanity CMS. Deployed on Vercel.

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

OMS Tech 27 Dec 3, 2022
NextJS E-commerce starter kit with Sanity.io and Stripe API 🛍

?? Next.js Sanity E-commerce Starter Kit A Next.js E-commerce app with Sanity.io and Stripe API. Built with TailwindCSS framework & SASS CSS extension

Lougie Quisel 11 Dec 29, 2022
The backend for our Airbnb App, built using Sanity.io.

AirBnb Sanity.io Backend This repository is to support my tutorial on how to build an AirBnb Clone with strucutred content using Sanity.io and Next.js

Ania Kubow 73 Dec 28, 2022
Airbnb-sanity - 🧳 Chrome extension to hide Airbnb listings you don't like

Airbnb Sanity ?? Coming soon to the Chrome Webstore! Chrome extension to hide Airbnb listings you don't like. Tired of looking through the same Airbnb

Johannes Rieke 4 Apr 4, 2022
Rede social baseada no ShareMe para compartilhamento e download de fotos em React,Sanity.io e TailWindCSS

Photophan ?? Descrição phothopan é uma rede social para o compartilhamento e download de imagens,foi desenvolvida utilizando React(Frontend),Sanity(Ba

Bruno Ariel 2 Jan 8, 2022
This is the repo for the Medium2 project with Next.js, Sanity CMS, React and Tailwind CSS

Next.js + Tailwind CSS Example This example shows how to use Tailwind CSS (v3.0) with Next.js. It follows the steps outlined in the official Tailwind

null 1 Jan 22, 2022
Javascript client for Sanity. Works in node.js and modern browsers (older browsers needs a Promise polyfill).

@sanity/client Javascript client for Sanity. Works in node.js and modern browsers (older browsers needs a Promise polyfill). Requirements Sanity Clien

Sanity 23 Nov 29, 2022
Medium-Clone with Next.JS, Typescript, Tailwindcss, and Sanity!!

Medium Clone ?? Overview /pages ✔️ pages/index.tsx = Homepage and list all Blogs ✔️ pages/post/[slug].tsx = Details Blog /pages/api ✔️ pages/api/creat

argikurnia 23 Nov 16, 2022
Monorepo for open source libraries used by nrkno-sanity

NRK.no Sanity libraries NRK.no Sanity libraries contains an assortment of plugins and libraries used by NRK.no to extend Sanity Studio and apps using

Norsk rikskringkasting (NRK) 10 Nov 30, 2022
Stablo is a minimal blog website template built with Next.js, TailwindCSS & Sanity CMS

Stablo Blog Template - Next.js & Sanity CMS Stablo is a JAMStack Starter template built with Next.js, Tailwind CSS & Sanity CMS by Web3Templates. Clic

Web3Templates 159 Dec 30, 2022
Sanity plugin for viewing resources which reference a particular resource.

@indent-oss/sanityio-referenced-by Plugin to see which documents reference a particular document referenced-by-sanityio.mov Video Alt Text: Demonstrat

Indent 16 Nov 2, 2022
Enhanced Sanity.io plugin development experience.

@sanity/plugin-kit NOTE This is a developer preview package meant for Sanity Studio v3 plugin development. For a v2 alternative, consider using Sanipa

Sanity 40 Dec 27, 2022
My personal website – Built using Next.js, TypeScript, MDX, Sanity.io and Tailwind

kenaqshal.com Framework: Next.js Database: PlanetScale ORM: Prisma Authentication: NextAuth.js Deployment: Vercel CMS: Sanity Styling: Tailwind CSS Ov

Ken Aqshal Bramasta 6 Nov 24, 2022
A minimal e-commerce store using Gatsby, SANITY, Stripe, Use-Shopping-Cart and Netlify

?? Gatsby Starter Stripemart Like a supermarket but for Stripe. No ongoing monthly costs. Perfect for artists, creators and independent builders doing

Eric Howey 26 Nov 14, 2022
Generate social preview images in your Next.js API from Sanity webhooks

sanity-next-social-image-generator Automatically generate social share images using Sanity webhooks, and your Next.js API! Requirements A Next.js appl

Jordan McRae 9 Sep 4, 2022
Fully featured clean-css plugin for Visual Studio Code

vscode-clean-css Fully featured clean-css plugin for Visual Studio Code. Install Execute Extensions: Install Extensions command from Command Palette (

Shogo Sensui 2 Nov 9, 2021
official Alibaba Design system vue components snippets for visual studio code

Alibaba DLS Snippets for vscode Installation You can either install this extension by searching for Alibaba DLS Snippets in your vscode extensions sto

Alibaba Travels Co Open Source 2 Sep 25, 2021
Visual Studio Code extension for formatting and linting Django/Jinja HTML templates using djLint

Visual Studio Code extension for formatting and linting Django/Jinja HTML templates using djLint

Almaz 25 Dec 15, 2022
Hands-on lab for Power Platform Tools for Visual Studio Code

Power Platform Tools for Visual Studio Code Lab This repository contains the lab instructions and content on how to experience the Power Platform Tool

Microsoft 8 Dec 1, 2022