Nextjs Is opinionated Where We Don’t Want

In recent project i’ve decided once again, Following some R&D research and digging into few technologies to pick Nextjs. The project scale at the beginning is not so high, and in regards to things like database I could pick whatever I want with the help of building route API in Nextjs. This framework doesn’t force me into a specific DB and even when it comes down to styling, I could use whatever I want. and since i’ve already work with a designer and front end expert that gave me a basic HTML and CSS i could easily integrate those and remove the nextjs CSS build in approach. in fact I’ve decided to add SASS to my project of Nextjs (which is not build in into nextjs) and it was, as well, a breeze. There are more consideration into the selection of Nextjs over other technologies, But before we continue Let’s take a look at the following table:


Aspect
Next.js OpinionWhy You Might Not Want It
File-Based RoutingEnforces routing based on the file structure in the pages directory.Limits flexibility if you prefer defining routes separately or using a different routing strategy.
SSR and SSGEmphasizes Server-Side Rendering (SSR) and Static Site Generation (SSG) with built-in support.Restrictive if you prefer client-side rendering or a different data-fetching approach.
Built-In API RoutesProvides built-in API routes limited to serverless functions.May be limiting if you have a complex backend or prefer managing APIs separately.
Automatic Static OptimizationAutomatically optimizes pages for static export if they don’t contain server-side logic.Can interfere with your desired rendering behavior and architecture control.
Webpack ConfigurationAbstracts Webpack configuration, providing easy-to-use default settings.Reduces control if you need deep Webpack customization or prefer using a different build tool (e.g., Vite).
Building product? put aside the infra and jump in with nextjs!

Your Goals

Is to build infrastructure, become tech lead, experiment with technologies, extend your knowledge of software engineering with complex topics – or to build a product, build a service and make money with a MVP? But mind you, that even if your goals are to be more knowledgeable as a software infrastructure or software architect it is still! over kill to build your own SSR, file base routing or even banging your head on a webpack configuration! And i haven’t mention reactjs, which comes out of the box. or integration with other popular software tools and libraries like typescript or SASS or database management like mongoose/mongodb and much more that are all, super, easy to integrate!

If you haven’t done so, I’d recommend you to try and write a basic todo web application that is build on top of Nextjs setup with React, typescript and other technologies: Build your first Todo App with Nextjs

Nextjs Common Questions

Let me try and answer some common questions that I’ve seen looking over popular engineering forums like stackoverflow, reddit and more. just to get an idea of what you get and what you don’t get from NextJS as an opinionated but not strict framework.

QuestionAnswer
What is Next.js used for?Next.js is used for building React-based web applications with features like server-side rendering (SSR), static site generation (SSG), and API routes.
Is Next.js better than React.js?Next.js is not necessarily better than React.js; it’s built on top of React and adds features like SSR, SSG, and routing. They serve different purposes.
Is Next.js frontend or backend?Next.js is a full-stack framework; it handles both frontend (React components) and backend (API routes, SSR) functionality.
Is Next.js better than Node.js?Next.js and Node.js serve different purposes. Next.js is a web framework built on top of Node.js for React apps, while Node.js is a runtime for server-side JavaScript.
Can I use Next.js without a backend?Yes, you can use Next.js without a separate backend by utilizing its built-in API routes for backend-like functionality.
Does Next.js replace the backend?Next.js can replace a traditional backend for many use cases by using its API routes, but for complex applications, a dedicated backend might still be needed.
Can Next.js replace React?No, Next.js cannot replace React. It extends React by providing additional features like SSR and routing but relies on React for the frontend.
Is Next.js full-stack?Yes, Next.js is considered a full-stack framework, as it allows you to build both the frontend and backend parts of a web application.
What is Next.js not good for?Next.js is not ideal for non-React-based applications, extremely dynamic applications requiring complex real-time interactions, or those requiring deep customization of build tools.
Is Next.js hard to learn?Next.js is not hard to learn, especially if you’re already familiar with React. It has a learning curve but provides extensive documentation and community support.
Can I learn Next.js without React?It’s possible to learn Next.js without React, but it’s highly recommended to have a solid understanding of React first, as Next.js is built on top of React.
Is Next.js still popular?Yes, Next.js is still popular due to its powerful features like SSR, SSG, and API routes, making it a go-to choice for many modern web applications.

The last thing I should mention is the fact that NextJS is easy to integrate out of, if down the road you’ll need or want to scale up parts of your application, Be it the API that needs to be more robust with NestJS or the database that needs to be on something other than popular solutinos or even if you’d choose to config your own Webpack because your code growth exceed whats NextJS provides – you might need micro frontends – It’s all good, with Nextjs you’ll be able and scale up any parts of your code!

Leave a Reply

Your email address will not be published. Required fields are marked *

All rights reserved 2024 ©