Why you should use Next.JS

Riaz Virani
Aug 23, 2017 · 2 min read

For our public marketing site at Hexient Labs, we use a React-based framework called Next.JS. It’s an amazing little piece of engineering and you should definitely consider it for your next project. In the rest of this post, I’m not going to do a technical walkthrough. The official Next.JS tutorial is amazing and you can easily learn the entire API in one to two hours. Instead, I’m going to talk about why you should use it. If you’re used to the standard React stack with Babel, WebPack, ES6, Redux, React-Router, etc, then you should know that the only piece React.JS replaces is React-Router and the build process. You can use everything else just as you normally would. Curious…well…

So TLDR, here’s what Next.JS does. It’s a really small framework that makes it easy to write server-renderable React apps. It doesn’t replace React. It just enforces a lightweight file and folder pattern and takes over the routing layer. Also that doesn’t mean it always server-renders. The people at Next.JS have come up with some ingenious tricks to allow your first load to be server-rendered, which means the site will work out of the box for SEO purposes and first render is really fast. However, subsequent page loads can be prefetched so users still get a nearly instantaneous interaction for additional page loads. Pretty impressive, eh? In order to do this, you essentially use the Next.JS routing and build infrastructure instead of react-router and a custom webpack build.

Secondly, Next.JS provides true code splitting out of the box. Each route is considered a unique entry point into the app and only loads the dependencies that are needed on that route. There is no single massive bundle the user must download! Yet as Next.JS loads or prefetches additional routes, it only downloads what it needs that’s extra. It’s magical!

So go check it out. Spend an hour and you’ll probably learn all of it!

hexient-labs

Tiny thoughts from the team at Hexient Labs

)

    Riaz Virani

    Written by

    hexient-labs

    Tiny thoughts from the team at Hexient Labs

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade