Skip to content

Commit

Permalink
No ssr for next.js app router until add support for RSC
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAMathews committed Jan 17, 2025
1 parent 8ff2a0e commit 0149400
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 0 additions & 2 deletions examples/nextjs/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import "./style.css"
import "./App.css"
import { ElectricScripts } from "@electric-sql/react"

export const metadata = {
title: `Next.js Forms Example`,
Expand All @@ -21,7 +20,6 @@ export default function RootLayout({
{children}
</header>
</div>
<ElectricScripts />
</body>
</html>
)
Expand Down
17 changes: 10 additions & 7 deletions examples/nextjs/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { preloadShape } from "@electric-sql/react"
import { itemShapeOptions } from "./items"
import { ItemsList } from "./items-list"
import dynamic from 'next/dynamic'
import "./Example.css"

export default async function Page() {
// Preload shape data during SSR
await preloadShape(itemShapeOptions)
// Dynamic import of ItemsList with SSR disabled
const ClientItemsList = dynamic(
() => import('./items-list').then(mod => mod.ItemsList),
{
ssr: false,
}
)

return <ItemsList />
export default function Page() {
return <ClientItemsList />
}
2 changes: 1 addition & 1 deletion examples/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"backend:up": "PROJECT_NAME=nextjs-example pnpm -C ../../ run example-backend:up && pnpm db:migrate",
"backend:down": "PROJECT_NAME=nextjs-example pnpm -C ../../ run example-backend:down",
"db:migrate": "dotenv -e ../../.env.dev -- pnpm exec pg-migrations apply --directory ./db/migrations",
"dev": "next dev --turbo -p 5173",
"dev": "next dev --turbo -p 5174",
"build": "next build",
"start": "next start",
"format": "eslint . --fix",
Expand Down

0 comments on commit 0149400

Please sign in to comment.