This content originally appeared on DEV Community and was authored by Gabriel Valin
Nowadays most developers uses express by default to build a new Node.JS app. It's is popular, easy to use and even Nest.JS uses it behind the scenes.
But if you take a look at the Fastify docs, you’ll see that it works quite differently from Express:
- Fastify uses fast-json-stringify by Matteo Collina with built-in functions based on schemas for serialize objects too fast
- Fastify uses a radix tree for routing - a compact and optimized tree built during server setup.
- It’s minimalist, with a strong focus on core performance
- Native validation using JSON Schema via Ajv
Express working as well but for optimization...
- Express uses JSON.stringify for serialize objects
- Linear routing based on route definition
- Minimalist but depends on directly middlewares
- No native validation
Below, you can see two files with simple implementations using Express and Fastify.I also ran a quick benchmark with Autocannon, and here are the results:
Express might feel comfortable, but give Fastify a try at least once.
Ref:
https://fastify.dev/docs/v2.15.x/Documentation/Server/
https://ankitpandeycu.medium.com/unleashing-the-potential-of-radix-tree-35e6c5d3b49d
https://www.npmjs.com/package/fast-json-stringify
https://fastify.dev/benchmarks/
This content originally appeared on DEV Community and was authored by Gabriel Valin

Gabriel Valin | Sciencx (2025-06-02T18:02:39+00:00) Why should you consider Fastify for your Node.JS app. Retrieved from https://www.scien.cx/2025/06/02/why-should-you-consider-fastify-for-your-node-js-app/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.