Next.js Discord

Discord Forum

Best Practice for Sharing Prefilled RichTextEditor Component Across Create and Edit Routes in Next.j

Unanswered
swanandaaaaa posted this in #help-forum
Open in Discord
Avatar
I have a RichTextEditor component that I'm using in two routes with the Next.js App Router:

/blogs/create — The editor is empty for creating a new blog post.
/blogs/edit/[slug] — The editor is prefilled with existing blog content for editing.

My Questions:
1. Should I call the editor separately in both /create/page.tsx and /edit/[slug]/page.tsx, or is it better to use a shared layout.tsx file for these routes?
2. If I do use a layout.tsx, how should I structure the pages?

Specifically:
Should I fetch the blog data in layout.tsx only when the pathname matches /edit/[slug] and then pass it to RichTextEditor?

Both routes only contain the RichTextEditor without any additional content, so I'm wondering if a shared layout is best practice in this case.

What’s the recommended approach here for a clean, maintainable setup because the RichTextEditor package is quite heavy?

2 Replies

Avatar
anyone???
Avatar
hello??