Next.js Discord

Discord Forum

dynamic route with client side rendering

Answered
Cão Fila de São Miguel posted this in #help-forum
Open in Discord
Cão Fila de São MiguelOP
Is it possible to implement dynamic route in next.js with client side rendering
Answered by Plott Hound
Try this the dynamic routes:

export const dynamic = 'force-static'
View full answer

13 Replies

Cão Fila de São MiguelOP
I want to load it statically but in my build it is Dynamic

Route (app)                              Size     First Load JS
┌ ○ /                                    55.9 kB         242 kB
├ ○ /_not-found                          0 B                0 B
├ ○ /home                              47.9 kB         280 kB
├ λ /games/[slug]                 8.54 kB         207 kB
└ λ /groups/[id]                  10.5 kB         231 kB
+ First Load JS shared by all            95.7 kB
  ├ chunks/607-b94e279423cc8c9c.js       11.3 kB
  ├ chunks/69-48da2e2a9ab30978.js        29 kB
  ├ chunks/fd9d1056-b385985c66e965ea.js  53.4 kB
  â”” other shared chunks (total)          2.04 kB


â—‹  (Static)   prerendered as static content
λ  (Dynamic)  server-rendered on demand using Node.js
Plott Hound
Try this the dynamic routes:

export const dynamic = 'force-static'
Answer
Plott Hound
Do you want to statically render all of the pages within the dynamic routes?
Cão Fila de São MiguelOP
I think this approach falls into ISR
@Cão Fila de São Miguel I think this approach falls into ISR
no, export const dynamic = 'force-static' works actually, try it
at least for this
import { Content } from "./content";

export const dynamic = "force-static";

export default function Page() {
  return <Content />;
}


"use client";
import { useParams } from "next/navigation";

export function Content() {
  const params = useParams();
  return <div>{JSON.stringify(params.slug)}</div>;
}
Cão Fila de São MiguelOP
got it
thanks
Also can you help me with generate-static-params for dynamic routes, i want to have slug folder.
i am getting slug from url not from api, Prevoius we would have to these configs in next.config.js now things are changed with app router.
Cão Fila de São MiguelOP
Sure, Thank you