Skip to content

Commit

Permalink
back to stable
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Nov 21, 2024
1 parent c9f01cb commit 25912da
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 181 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ instead of defining your own `sanityFetch` function and `SanityLive` component.
- [Remix](./remix/)
- [Nuxt](./nuxt/)
- [SvelteKit](./sveltekit/)
- [Next.js with Enterprise grade revalidation efficiency](./next-enterprise/) - [https://lcapi-examples-next-enterprise.sanity.dev/] – uses Next.js 15's `use cache` directive, but doesn't require it, and the technique could be used in any framework that supports on-demand revalidation similar to ISR in Next.js on Vercel.
- [Next.js with Enterprise grade revalidation efficiency](./next-enterprise/) - [https://lcapi-examples-next-enterprise.sanity.dev/] – uses Next.js 15, but doesn't require it, and the technique could be used in any framework that supports on-demand revalidation similar to ISR in Next.js on Vercel.
6 changes: 1 addition & 5 deletions next-enterprise/next.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import type {NextConfig} from 'next'

const nextConfig: NextConfig = {
experimental: {
dynamicIO: true,
},
}
const nextConfig: NextConfig = {}

export default nextConfig
4 changes: 2 additions & 2 deletions next-enterprise/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"@sanity/client": "^6.22.5",
"groq": "^3.64.2",
"next": "canary",
"next": "15.0.3",
"react": "rc",
"react-dom": "rc",
"use-effect-event": "^1.0.2"
Expand All @@ -22,7 +22,7 @@
"@types/react": "npm:types-react@rc",
"@types/react-dom": "npm:types-react-dom@rc",
"eslint": "^9.15.0",
"eslint-config-next": "canary",
"eslint-config-next": "15.0.3",
"postcss": "^8.4.49",
"tailwindcss": "^3.4.15",
"typescript": "^5.6.3"
Expand Down
7 changes: 3 additions & 4 deletions next-enterprise/src/sanity/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {type QueryParams} from '@sanity/client'
import {unstable_cacheTag as cacheTag} from 'next/cache'
import {client} from './client'

export async function sanityFetch<const QueryString extends string>({
Expand All @@ -9,11 +8,11 @@ export async function sanityFetch<const QueryString extends string>({
query: QueryString
params?: QueryParams
}) {
'use cache'
const {result, syncTags} = await client.fetch(query, params, {
const {syncTags: tags} = await client.fetch(query, params, {
filterResponse: false,
returnQuery: false,
})
cacheTag(...(syncTags as string[]))
const {result, syncTags} = await client.fetch(query, params, {next: {tags}})

return {data: result, tags: syncTags, fetchedAt: new Date().toJSON()}
}
Loading

0 comments on commit 25912da

Please sign in to comment.