Retrieving data - Next.js 14 Server Components 🫤
Answered
Alaska pollock posted this in #help-forum
Alaska pollockOP
Hey,
I just switched to Next.js 14 and its server components. Need some tips on pulling data the right way. I’ve got this page listing all my data entries in a table. Now, I want to make it so that when you click on any entry, it grabs the ID and takes you to a new page showing more about it. It'll hit my API with that ID to get the details.
Im not sure if I need to create a dynamic page [id].tsx, Pass the id as a route param to my /details page.tsx, or use some weird server component that will get my data magically.
Any advice on this would be great. Sick to death of banging my head against the wall with these silly server components
I just switched to Next.js 14 and its server components. Need some tips on pulling data the right way. I’ve got this page listing all my data entries in a table. Now, I want to make it so that when you click on any entry, it grabs the ID and takes you to a new page showing more about it. It'll hit my API with that ID to get the details.
Im not sure if I need to create a dynamic page [id].tsx, Pass the id as a route param to my /details page.tsx, or use some weird server component that will get my data magically.
Any advice on this would be great. Sick to death of banging my head against the wall with these silly server components
13 Replies
Yup, you will make a dynamic page [id].tsx for the individual pages.
Alaska pollockOP
Why do I get 404 for
http://localhost:3000/creation/ai-detail/123the folder has to be [id]
and inside it is page.tsx
Alaska pollockOP
wow super fast reply you legend
need them points :D
works now?
Alaska pollockOP
this looking ok?
router.query.id? thats wrong
where did you import router from btw
Alaska pollockOP
legendddddd
Working