What's the point of using NextJS?

Gepostet von Oscar am 20.09.2021

NextJS ui frontend

NextJS allows for the creation of fast applications and websites by creating pages using React components.

Okay, but what does it do for me as a developer?

First of all, it supports Typescript, which, depending on which side of the fence you sit on, could be a pro or a con. One of the best features is fast refresh, which is pretty self-explanatory. However, there are some caveats that you should keep in mind, e.g. in class components the state is not preserved, since it only supports function components and hooks.

How do I navigate my application?

Routing is easy and already integrated. If the file is in the pages folder, it’s easily accessible: just add a path to it. Done!

Do you like CSS?

Just import it into your _app.js file:

> import ‘../my-styles.css’

Or if you prefer being sassy:

> import ‘../im-sassy.scss’

“But I don’t like standard stylesheets,” I hear you say.

Well, here are some other flavours just for you:

  • Inline styles
  • Emotion
  • Linaria

Do you find runtime errors annoying?

I certainly do. When a browser throws a runtime error, the entire page usually just stops working.

NextJS implements an error boundary for us and displays an overlay whenever this happens, which avoids breaking the entire page. Then, if the error is fixed, the overlay will disappear on its own. Hey, one less thing to worry about is always good.

“But I don’t like React. :(”

Fine, have it your way, try NuxtJS: same thing – different flavour.

“Your arguments still don’t convince me.”

I don’t have to convince anyone – just take a look at the people who use it. If it’s good enough for them, it’s probably good enough for you.

tl;dr: Fast & easy development (speeeeed). There’s also “some” SEO if you’re interested.