Code review for first Next.js project

I have just completed my first Next.js project and would love some feedback particularly around folder structure and naming conventions.

I have a long term goal of creating a demo/template so I want to make sure that it is best or at least good practice.

Thanks in advance.

Repo
https://github.com/Headlesshost/react.nextjs.knowledgebase

Open https://react-nextjs-knowledgebase.vercel.app/knowledgebase/gs_intro for a live demo of the app.

2 Likes

You’re off to a good start, @headlesshost! I asked the Next.js folks for some tips, and this is what they shared:

I hope that helps :smile:

When you’re ready, you can use this submission form to share it for potential inclusion in the Vercel Templates Marketplace: Vercel Template Submission Form

Thanks @amyegan , that is really helpful feedback.

The redirect issue is something I struggled with. :thinking:

In Headlesshost “staging content sites” are transient and users can create multiple versions to suit their needs. These multiple versions of content are rendered by a single staging website (Next.js). The website knows what version of content to render as the version instance id is passed in the url.

How the staging URL is configured in Headlesshost

https://react-nextjs-knowledgebase-git-fac832-warren-cheethams-projects.vercel.app/{instance}

How it resolves with one of the instances

https://react-nextjs-knowledgebase-git-fac832-warren-cheethams-projects.vercel.app/b08ca852-7166-475c-a3d5-157cdcd74209

So I’m putting the instance id in the route to hold state, which is not ideal. When rendering production content it just uses “knowledgebase” as a placeholder.

I could use query strings but I would need to add them to every navigation link. The route links are relative so they just work.

If you have any suggestions on better ways to handle this I would really appreciate the feedback.

I accidentally deleted my site when testing the deploy button. Below are the new links. I have bumped the next version and deleted the vercel.json:

Staging content
https://react-nextjs-knowledgebase.vercel.app/b08ca852-7166-475c-a3d5-157cdcd74209

Production content
https://react-nextjs-knowledgebase.vercel.app/knowledgebase

Repository