Skip to main content

Next JS

A fantastic framework for prototyping and quickly building applications.


I'd like to love it more, but have some gripes on the server side of things. Here's a running list. I'm sure there's a better way to do it, if not someone is probably thinking about possible solutions.

Authenticated routes

Right now, I do an if condition in all API routes and return early if not authenticated. A fragile setup.

Returning TS classes & HTTP exceptions from endpoints

At the end of every endpoint, the expectation is to res.status(200).send({}) and then mention a return type. I would prefer how NestJS does it, if a serializable typescript type is returned, send it back as a success response. If an Exception of type HTTP is thrown with a body, return the corresponding err with that body. Would be much more elegant!

Global error handling

Looks like the way global error handling is done is by wrapping up all the endpoints around a custom HOC.

Type validation from TS types

This might be out of scope for the NextJS framework, but I think there should be a recommended way of doing type validation using Zod or class validator.