next-sanity 5.5.2 → 5.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +10 -4
  2. package/package.json +8 -8
package/README.md CHANGED
@@ -463,7 +463,7 @@ The [same is true][preview-kit-livequery] for `next-sanity/preview/live-query`.
463
463
 
464
464
  ### Using `draftMode()` to de/activate previews
465
465
 
466
- Next.js gives you [a built-in `draftMode` variable][draft-mode] that can be used to activate features like Visual Edit or any preview implementation.
466
+ Next.js gives you [a built-in `draftMode` variable][draft-mode] that can activate features like Visual Edit or any preview implementation.
467
467
 
468
468
  ```ts
469
469
  // ./src/utils/sanity/client.ts
@@ -505,21 +505,26 @@ export async function sanityFetch<QueryResponse>({
505
505
  throw new Error('The `SANITY_API_READ_TOKEN` environment variable is required.')
506
506
  }
507
507
 
508
+ const REVALIDATE_SKIP_CACHE = 0
509
+ const REVALIDATE_CACHE_FOREVER = false
510
+
508
511
  return client.fetch<QueryResponse>(query, params, {
509
- cache: 'force-cache',
510
512
  ...(isDraftMode && {
511
- cache: undefined,
512
513
  token: token,
513
514
  perspective: 'previewDrafts',
514
515
  }),
515
516
  next: {
516
- ...(isDraftMode && {revalidate: 30}),
517
+ revalidate: isDraftMode ? REVALIDATE_SKIP_CACHE : REVALIDATE_CACHE_FOREVER,
517
518
  tags,
518
519
  },
519
520
  })
520
521
  }
521
522
  ```
522
523
 
524
+ #### Using `cache` and `revalidation` at the same time
525
+
526
+ Be aware that you can get errors if you use the `cache` and the `revalidate` configurations for Next.js cache at the same time. Go to [the Next.js docs][next-revalidate-docs] to learn more.
527
+
523
528
  ## Visual Editing with Content Source Maps
524
529
 
525
530
  > **Note**
@@ -745,6 +750,7 @@ MIT-licensed. See [LICENSE][LICENSE].
745
750
  [next-cache]: https://nextjs.org/docs/app/building-your-application/caching
746
751
  [next-data-fetching]: https://nextjs.org/docs/basic-features/data-fetching/overview
747
752
  [next-preview-mode]: https://nextjs.org/docs/advanced-features/preview-mode
753
+ [next-revalidate-docs]: https://nextjs.org/docs/app/api-reference/functions/fetch#optionsnextrevalidate
748
754
  [pages-router]: https://nextjs.org/docs/pages/building-your-application/routing
749
755
  [personal-website-template]: https://github.com/sanity-io/sanity-template-nextjs-app-router-personal-website
750
756
  [perspectives-docs]: https://www.sanity.io/docs/perspectives?utm_source=github&utm_medium=readme&utm_campaign=next-sanity
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-sanity",
3
- "version": "5.5.2",
3
+ "version": "5.5.4",
4
4
  "description": "Sanity.io toolkit for Next.js",
5
5
  "keywords": [
6
6
  "sanity",
@@ -177,7 +177,7 @@
177
177
  "@sanity/preview-kit": "3.1.6",
178
178
  "@sanity/webhook": "3.0.1",
179
179
  "groq": "^3.0.0",
180
- "@sanity/client": "^6.4.11"
180
+ "@sanity/client": "^6.4.12"
181
181
  },
182
182
  "devDependencies": {
183
183
  "@next/bundle-analyzer": "^13.4.19",
@@ -185,15 +185,15 @@
185
185
  "@rollup/plugin-url": "^8.0.1",
186
186
  "@sanity/eslint-config-studio": "^3.0.1",
187
187
  "@sanity/image-url": "^1.0.2",
188
- "@sanity/pkg-utils": "^2.4.8",
188
+ "@sanity/pkg-utils": "^2.4.9",
189
189
  "@sanity/ui": "^1.8.2",
190
190
  "@sanity/vision": "3.16.4",
191
191
  "@types/eventsource": "^1.1.11",
192
- "@types/jest": "^29.5.4",
193
- "@types/react": "^18.2.21",
192
+ "@types/jest": "^29.5.5",
193
+ "@types/react": "^18.2.22",
194
194
  "@types/react-dom": "^18.2.7",
195
195
  "@types/styled-components": "^5.1.27",
196
- "@typescript-eslint/eslint-plugin": "^6.7.0",
196
+ "@typescript-eslint/eslint-plugin": "^6.7.2",
197
197
  "autoprefixer": "^10.4.15",
198
198
  "eslint": "^8.49.0",
199
199
  "eslint-config-prettier": "^9.0.0",
@@ -206,14 +206,14 @@
206
206
  "jest-environment-jsdom": "^29.7.0",
207
207
  "ls-engines": "^0.9.0",
208
208
  "next": "13.4.19",
209
- "postcss": "^8.4.29",
209
+ "postcss": "^8.4.30",
210
210
  "prettier": "^3.0.3",
211
211
  "prettier-plugin-packagejson": "^2.4.5",
212
212
  "prettier-plugin-tailwindcss": "^0.5.4",
213
213
  "react": "^18.2.0",
214
214
  "react-dom": "^18.2.0",
215
215
  "react-is": "^18.2.0",
216
- "rollup": "^3.29.1",
216
+ "rollup": "^3.29.2",
217
217
  "sanity": "3.16.4",
218
218
  "server-only": "^0.0.1",
219
219
  "styled-components": "^5.3.11",