When to use NextJS instead of just React?
TL,DR: For anything not business related, are there usecases better suited for Next than plain React+Vite, vanilla JS and some libs?Asking here because I haven't quite understood from my research (I may be stupid :happy: ). My background is as a Game Developer, am currently learning front-end with a few one-page projects, and my backend experience is limited to university projects and SQL queries. In games, we typically have the user's machine store and process everything (even something like Wordle could use a local library and pass a date to get a word). So when I began front-end stuff that was my approach as well, first with just vanilla JS (like those Hyperplexed videos) then moved to React. Even when I made forms they'd be processed in the client to generate a final result. I also used PokeAPI when trying to make a more advanced app but the lack of filtered endpoints (say, just the sprites instead of gathering the entire entry) made me want to make it an offline mobile/desktop app with baked data instead. Maybe it's because all my project ideas are small tools or toys that can be processed in the client, and don't use a lot of data, and my general familiarity with backend in general and NextJS in particular, but I still can't grasp it. Are there any kinds of small apps that want the server processing / server rendering that Next provides or does that only pop up when you need auth and payment processing and stuff? Thanks in advance from a noob dev.
Solution:Jump to solution
That's a very interesting question! 😊
And, as always, the answer depends on the specific needs of your project. (I know that sounds a bit vague, but stay with me—I'll explain.)
If your application or website relies on SEO—for example, a blog or an article-based platform—then server-side rendering (SSR) is essential. In this case, you'll want to ensure all the necessary data is rendered on the server so that crawlers can index a fully populated HTML page, instead of just seeing an empty <div id="root"></div>.
...
3 Replies
Solution
That's a very interesting question! 😊
And, as always, the answer depends on the specific needs of your project. (I know that sounds a bit vague, but stay with me—I'll explain.)
If your application or website relies on SEO—for example, a blog or an article-based platform—then server-side rendering (SSR) is essential. In this case, you'll want to ensure all the necessary data is rendered on the server so that crawlers can index a fully populated HTML page, instead of just seeing an empty <div id="root"></div>.
If you're looking to obfuscate or protect your actual API endpoints, you can take advantage of Next.js API routes to handle server-side logic securely.
Finally, if you're working on a fullstack project and need to build an API for your frontend, Next.js is still a great choice. You can either define a traditional API layer or adopt the newer React Server Components paradigm, which allows you to make direct calls to your database (for example) from within your server-side components—no separate API layer needed in some cases.
A great usecase for SEO optimisation is a CMS (Content Managment System).
You can look around PayloadCMS (a NextJS based CMS).
i didn't even know about the SEO thing, that explains a lot!
if the whole content is built in the client the crawlers have nothing to work with.
i'll also look into those usecases, thank you!