Quick answer: Node.js web development fits best when your application spends most of its time waiting on other things, such as databases, APIs, file storage or users, rather than doing heavy calculation. That makes it a good match for APIs behind web and mobile apps, real time features like chat and live dashboards, integration services that connect SaaS tools, and projects where the same JavaScript team builds front end and back end. It is a weaker fit for CPU heavy work such as large report generation, image processing or complex calculations, unless that work is moved into separate services. Choose a current LTS version, a structured framework, and treat dependency security seriously.
What Node.js is
Node.js is a runtime that lets JavaScript run on a server instead of only in the browser. It uses the V8 engine from Google Chrome and an event driven, non blocking model for input and output.
In plain terms, when a Node.js server asks the database for data, it does not sit and wait. It moves on to handle other requests and comes back when the data is ready. That lets one process handle a large number of simultaneous connections efficiently, as long as each request does not hog the processor.
Current versions
Node.js has a predictable release schedule:
- Node.js 12 is the current long term support (LTS) line, recommended for most production applications
- Node.js 10 is the previous LTS line, still supported until April 2021
- Node.js 13 is the current release with newer features, but it will not become LTS
- Node.js 8 reached end of life at the end of December 2019, so applications still on it should be upgraded
New business applications should start on Node.js 12. LTS lines are supported for 30 months in total, which gives time to plan upgrades.
Where Node.js fits well
APIs for web and mobile apps
Most modern front ends, whether a single page application or a mobile app, talk to a back end through an API. Node.js is very good at receiving requests, checking permissions, talking to a database and returning JSON. Frameworks such as Express, Fastify and NestJS make building REST APIs straightforward. Our guide to REST API design covers how to structure one well.
Real time features
Chat, notifications, live order tracking, collaborative editing and live dashboards all need the server to push updates to the browser. Node.js handles many open WebSocket connections efficiently, and libraries such as Socket.IO make this approachable.
Integration and middleware services
Many business systems need a layer that connects the website, CRM, payment provider, accounting software and email platform. These services mostly pass data around and call other APIs, which is exactly the work Node.js does well. Most SaaS vendors also publish JavaScript SDKs.
Server rendering for JavaScript front ends
Frameworks such as Next.js for React and Nuxt.js for Vue render pages on the server with Node.js, so visitors and search engines get full HTML quickly. This helps when a JavaScript heavy site also needs to rank in search.
Prototypes and MVPs
A small team can build both ends in JavaScript and move quickly, which is useful when testing an idea before committing to a larger build.
Where Node.js is a weaker fit
CPU heavy work
Because a Node.js process handles requests on a single main thread, a long calculation blocks every other request on that process until it finishes. Examples include:
- Generating large PDF reports
- Resizing or processing images and video
- Complex pricing, scheduling or statistical calculations
- Large data transformations
Worker threads, stable since Node.js 12, and separate background job queues help. Often the better approach is to move heavy processing into a separate service, which might be written in another language.
Applications built around complex business rules
Large applications with intricate domain logic benefit from strong typing and structure. JavaScript can do this, but it needs discipline. TypeScript, which adds static types to JavaScript, closes much of the gap and is worth using on any sizeable Node.js codebase.
Teams without JavaScript experience
If your developers work mainly in another language and your systems are built around it, introducing Node.js adds a second stack to maintain. That cost is real.
Choosing a framework
Node.js itself is small, so most projects use a framework:
- Express: minimal and very widely used. Flexible, but you make most structural decisions yourself.
- Koa: from the team behind Express, smaller and built around modern async code.
- Fastify: focused on speed and low overhead, with a plugin system and schema based validation.
- NestJS: a structured, TypeScript first framework with modules, dependency injection and clear conventions. A good choice for larger business applications and teams.
- Hapi: configuration focused, with strong built in features for validation and security.
For a business application that will grow and be maintained by several developers, a structured framework with TypeScript usually pays off.
Data and architecture
Node.js works with all the common databases: PostgreSQL, MySQL, SQL Server, MongoDB and Redis. Tools such as Sequelize, TypeORM and Knex help with SQL databases, and Mongoose with MongoDB.
Decide early whether the application will be a single, well organised codebase or several smaller services. Starting with one codebase and splitting out services later, when there is a clear reason, is usually less risky. Our comparison of microservices vs monolith explains the trade offs.
If clients need flexible queries across many related objects, consider whether GraphQL suits better than REST. See GraphQL vs REST.
Hosting options
Node.js runs almost anywhere:
- Virtual private servers on Linux, with a process manager such as PM2 and a reverse proxy like Nginx
- Platform services such as Heroku, Azure App Service, AWS Elastic Beanstalk or Google App Engine
- Docker containers on a managed container service
- Serverless functions such as AWS Lambda, Azure Functions or Google Cloud Functions for event driven tasks
Run more than one process to use all CPU cores and to stay up if one process crashes. The built in cluster module or PM2 handles this.
Security and maintenance
The npm ecosystem is huge, which speeds up development, but every package you add is code you depend on. Good practice includes:
- Keeping dependencies few and well chosen
- Running
npm auditregularly and fixing reported issues - Locking versions with the package lock file
- Validating all input and using parameterised database queries
- Storing secrets in environment variables or a secrets manager, not in code
- Upgrading Node.js before your version reaches end of life
Plan for maintenance in the budget. Like any application, a Node.js app needs regular updates to stay secure.
Questions to ask before choosing Node.js
- Is the main work moving data between systems and users, or heavy calculation?
- Does the app need real time features?
- Does your team, or your agency, have strong JavaScript and TypeScript experience?
- What existing systems must it integrate with, and how good are their JavaScript libraries?
- Who will maintain it, and how will upgrades be handled?
FAQ
Is Node.js good for large applications?
Yes, with the right structure. Large Node.js applications usually use TypeScript, a structured framework such as NestJS, automated tests and clear module boundaries.
Is Node.js fast?
For I/O heavy work, very. For CPU heavy tasks, it is slower to respond overall unless that work is moved to worker threads or separate services.
Can Node.js replace PHP for my website?
For a content site, a CMS on PHP is often simpler. Node.js makes more sense for custom web applications, APIs and real time features.
Which Node.js version should we use?
The current LTS line, which is Node.js 12. Avoid odd numbered releases for production, as they are not long term supported.
Pick the tool that fits the job
Node.js is an excellent choice for APIs, integrations and real time features, and a poor one for heavy number crunching on its own. Matching it to the right job is what makes it work well. If you are planning a web application that needs to convert and scale, see our Turn visitors into customers service, or our Custom development service for bespoke builds.