#dynamic routes with server side rendering.
13 messages · Page 1 of 1 (latest)
🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord
🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in <id:customize>
✅ You can mark a message as the answer for your post with `Right click -> Apps -> Mark Solution`
(if you don't see the option, try refreshing Discord with Ctrl + R)
app router? use this params prop and retrieve the post data server-side https://nextjs.org/docs/app/api-reference/file-conventions/page#params-optional
Could you give an example of getting the data server-side? is it as easy as literally fetching the data within the file? anythiing not marked use client is server rendered right? I think I anwsered my own question but lol
yeah basically...
export default async function Page({ params }) {
const post = await db.getPost({ id: params.id });
if (!post) notFound(); // render 404 page
return <div>{post.title}</div>;
}
you may also want to use generateStaticParams (https://nextjs.org/docs/app/api-reference/functions/generate-static-params)
Wouldn't generateStaticParams only gen the items in the db at the time of building the page?
like if users are activitly creating posts, and there are thousands of them?
but in this case, i would recommend just rendering everything dynamically yes
no need of generateStaticParams
in your case then just use something like this with export const revalidate = 0 at the bottom
okay thank you very much 