Next.js Discord

Discord Forum

Page with same content but for a new record vs edit record

Answered
Mourning Dove posted this in #help-forum
Open in Discord
Mourning DoveOP
Say I need a page with a form, and there's a /record/new and a /record/<UUID> version, where one is to create a new record, and one is to edit an existing record. How do you handle this with pages?

Do you simple have a single page component (/record/ in this case) and add a query param for new vs an existing record? Something like
/record/?record_id=new
/record/?record_id=<uuid>
Answered by alfon
id use client component to show a modal to create new
View full answer

5 Replies

Answer
and that component is in layout.tsx of /record
that way its always displayed regardless if you visit /record/1231241
ofc you could also do /record/new if you choose to have a whole page to create new record
Mourning DoveOP
Ok, awesome. thanks for your input!