diff --git a/apps/next-app-router/app/Variant.tsx b/apps/next-app-router/app/Variant.tsx
index 2637fad1..847d39c8 100644
--- a/apps/next-app-router/app/Variant.tsx
+++ b/apps/next-app-router/app/Variant.tsx
@@ -1,13 +1,12 @@
-import dynamic from 'next/dynamic'
+import { lazy } from 'react'
-const DefaultVariant = dynamic(() => import('./variants/default'))
-const GroqStoreVariant = dynamic(() => import('./variants/groq-store'))
-const LiveStoreVariant = dynamic(() => import('./variants/live-store'))
+const GroqStoreVariant = lazy(() => import('./variants/groq-store'))
+const LiveStoreVariant = lazy(() => import('./variants/live-store'))
export default function Variant(props: React.PropsWithChildren) {
switch (process.env.VARIANT || 'default') {
case 'default':
- return
+ return <>{props.children}>
case 'groq-store':
return
case 'live-store':
diff --git a/apps/next-app-router/app/layout.tsx b/apps/next-app-router/app/layout.tsx
index f46d8e6d..5aa61589 100644
--- a/apps/next-app-router/app/layout.tsx
+++ b/apps/next-app-router/app/layout.tsx
@@ -4,6 +4,8 @@ import { unstable__adapter, unstable__environment } from '@sanity/client'
import DraftModeButton from './DraftModeButton'
import type { Metadata } from 'next'
+export const runtime = 'edge'
+
export const metadata: Metadata = {
title: `next-app-router-${process.env.VARIANT || 'default'}`,
}
diff --git a/apps/next-app-router/app/page.tsx b/apps/next-app-router/app/page.tsx
index 48128cfc..fd4cccdd 100644
--- a/apps/next-app-router/app/page.tsx
+++ b/apps/next-app-router/app/page.tsx
@@ -16,6 +16,8 @@ import Variant from './Variant'
import { PreviewTable, PreviewFooter } from './previews'
import { Suspense } from 'react'
+export const runtime = 'edge'
+
export default async function Page() {
const footer = await sanityFetch({
query: footerQuery,
@@ -32,6 +34,7 @@ export default async function Page() {
initialData={footer}
query={footerQuery}
as={PreviewFooter}
+ throwOnMissingProvider={false}
>
@@ -53,6 +56,7 @@ async function ServerTable() {
initialData={data}
query={tableQuery}
as={PreviewTable}
+ throwOnMissingProvider={false}
>
diff --git a/apps/next-app-router/app/variants/default/index.tsx b/apps/next-app-router/app/variants/default/index.tsx
deleted file mode 100644
index 83dcab52..00000000
--- a/apps/next-app-router/app/variants/default/index.tsx
+++ /dev/null
@@ -1,3 +0,0 @@
-export default function DefaultVariant({ children }: React.PropsWithChildren) {
- return children
-}
diff --git a/apps/next-app-router/app/variants/groq-store/PreviewProvider.tsx b/apps/next-app-router/app/variants/groq-store/PreviewProvider.tsx
index 357ca2a6..16e9e3d0 100644
--- a/apps/next-app-router/app/variants/groq-store/PreviewProvider.tsx
+++ b/apps/next-app-router/app/variants/groq-store/PreviewProvider.tsx
@@ -16,12 +16,7 @@ export default function PreviewProvider({
const { client } = suspend(() => import('./sanity.client'), [UniqueKey])
if (!token) throw new TypeError('Missing token')
return (
-
+
{children}
)
diff --git a/apps/next-app-router/next.config.mjs b/apps/next-app-router/next.config.mjs
index 8079aeb8..6b933204 100644
--- a/apps/next-app-router/next.config.mjs
+++ b/apps/next-app-router/next.config.mjs
@@ -7,6 +7,7 @@ const nextConfig = {
fullUrl: true,
},
},
+ reactStrictMode: true,
serverActions: true,
productionBrowserSourceMaps: true,
// Support Vercel Authentication protection
@@ -21,7 +22,7 @@ const nextConfig = {
},
{
key: 'Content-Security-Policy',
- value: `frame-ancestors 'self' https://*.sanity.build`,
+ value: `frame-ancestors 'self' https://*.sanity.build http://localhost:3333`,
},
],
},
diff --git a/apps/next-pages-router/next.config.mjs b/apps/next-pages-router/next.config.mjs
index 1d08ba0b..123dd3e5 100644
--- a/apps/next-pages-router/next.config.mjs
+++ b/apps/next-pages-router/next.config.mjs
@@ -7,6 +7,7 @@ const nextConfig = {
fullUrl: true,
},
},
+ reactStrictMode: true,
productionBrowserSourceMaps: true,
// Support Vercel Authentication protection
async headers() {
@@ -20,7 +21,7 @@ const nextConfig = {
},
{
key: 'Content-Security-Policy',
- value: `frame-ancestors 'self' https://*.sanity.build`,
+ value: `frame-ancestors 'self' https://*.sanity.build http://localhost:3333`,
},
],
},
diff --git a/apps/next-pages-router/src/pages/index.tsx b/apps/next-pages-router/src/pages/index.tsx
index c4a39387..85e5b5b8 100644
--- a/apps/next-pages-router/src/pages/index.tsx
+++ b/apps/next-pages-router/src/pages/index.tsx
@@ -18,7 +18,7 @@ import {
tableQuery,
} from 'ui/react'
import dynamic from 'next/dynamic'
-import { useIsEnabled } from '@sanity/preview-kit'
+import { useIsEnabled, useLiveQuery } from '@sanity/preview-kit'
import { LiveQuery } from '@sanity/preview-kit/live-query'
import { sanityFetch, token } from '../sanity.fetch'
@@ -82,6 +82,8 @@ export default function Page(
client__environment: environment,
})
}, [])
+ const [table, , isLive] = useLiveQuery(props.table, tableQuery)
+ const [footer] = useLiveQuery(props.footer, footerQuery)
return (
@@ -93,22 +95,10 @@ export default function Page(
)}
-
-
-
-
-
-
+
+
{timestamp && }
-
+