diff --git a/next-canary/next.config.ts b/next-canary/next.config.ts index 4c17d31..04fd3a5 100644 --- a/next-canary/next.config.ts +++ b/next-canary/next.config.ts @@ -15,6 +15,7 @@ const nextConfig: NextConfig = { expire: 0xfffffffe, }, }, + ppr: 'incremental', }, } diff --git a/next-canary/src/app/dynamic/UserAgent.tsx b/next-canary/src/app/dynamic/UserAgent.tsx new file mode 100644 index 0000000..9c56b4b --- /dev/null +++ b/next-canary/src/app/dynamic/UserAgent.tsx @@ -0,0 +1,15 @@ +import {headers} from 'next/headers' + +export async function UserAgent() { + const headersList = await headers() + const userAgent = headersList.get('user-agent') + + return ( +
+ User Agent: + + {userAgent} + +
+ ) +} diff --git a/next-canary/src/app/dynamic/page.tsx b/next-canary/src/app/dynamic/page.tsx new file mode 100644 index 0000000..1ba67d3 --- /dev/null +++ b/next-canary/src/app/dynamic/page.tsx @@ -0,0 +1,47 @@ +import {sanityFetch} from '@/sanity/fetch' +import {defineQuery} from 'groq' +import type {Metadata} from 'next' +import {Suspense} from 'react' +import {TimeSince} from '../TimeSince' +import {UserAgent} from './UserAgent' + +const DEMO_QUERY = defineQuery(`*[_type == "demo" && slug.current == $slug][0].title`) +const slug = 'next-canary' + +export const experimental_ppr = true + +export async function generateMetadata(): Promise { + const {data} = await sanityFetch({query: DEMO_QUERY, params: {slug}}) + return { + title: data || 'Next Canary', + } +} + +export default async function Home() { + const {data, fetchedAt} = await sanityFetch({query: DEMO_QUERY, params: {slug}}) + + return ( + <> +
+

+ {data || 'Next Canary'} +

+ + + +
+ + User Agent: + + ... + + + } + > + + + + ) +}