6 Next JS Tips To Improve The UX Of Your Application

Ala Ben Aicha
6 min readMar 12, 2022

--

Build a world class web app with Next.JS

Introduction

There are tons of web development frameworks available in the market. It can be a challenging task for web-development companies to pick the web-development framework that fulfills their requirements. If you’re in a dilemma about which web development framework to select, we have a trick for you. Go for the framework that fits with your organizations’ goals and will also be convenient to maintain in the next five years.

In this article, I will discuss how can you get the best out of Next.JS to offer the best user experience for your customers.

What is good user experience?

User experience (UX) focuses on fully understanding how users interact with a brand or an interface. It requires a deep insight into the needs of users, what they like and value their abilities, and also in some cases their limitations. Implementing the best UX practices will improve the quality of the user’s interaction and enhance their perceptions of a brand and its product and services.

What impact has a bad UX on your application?

User experience plays a key role in the success (or failure) of web apps. If you don’t take care of UX of your website properly, it will lead to:

  • Losing customers
  • Low Google ranks
  • Abandoned carts
  • High bounce rate
  • Weak SEO
  • The lower organic and overall traffic
  • Drop in conversion rate

What is Next.JS?

Next.js is a React framework that enables developers to build performant web applications and blazingly fast static websites. Actually, Next.js’ feature called Automatic Static Optimization blends “static” and “dynamic” terms into one. Thanks to it, Next.js makes it possible to build hybrid applications containing both server-rendered and static-generated pages.

Developers (but not only them) choose Next because of:

  • Rich user experience (easier and faster)
  • Outstanding performance (also easier and faster)
  • Rapid feature development

Next.js pros

  • Fast page load time — Static websites are faster by default than dynamic ones, and as Next.js allows you to build one, your website will work in a blink of an eye.
  • Front-end freedom — Pre-made templates or themes do not limit you. Instead, you can design and customize the front-end, so it meets your needs and expectations.
  • Image optimisation — <image> and Automatic Image Optimization as default features.
  • Internationalization — Domain and subdomain routing, and automatic language detection.
  • Time-efficient — As the front-end is decoupled from the back-end, even non-technical people can easily make necessary changes to the UX/UI. Therefore, there won’t be as much pressure on the dev team to make desired changes as anybody can manage them in a more organized way.
  • Empowered marketing efforts — Next.js allows marketers to implement new features or interesting tools quickly to follow the latest trends in marketing.
  • Zero config — Focus on the business logic, not on the application logic.
  • Incremental Static Generation — This feature automatically updates existing pages by re-rendering them in the background while traffic comes in.
  • Hybrid of Static Site Rendering and Static Site Generation — Prerender pages at build time or request time in a single project.
  • TypeScript support — Automatic TypeScript configuration and compilation.
  • Fast refresh — Fast, live-editing experience.

Next.js tips for a better UX

1. Loading screen

Loading screens are a good place to start our journey for improving the feel of our applications. With Next.JS 12, now you can use URL imports that allow you to import modules directly from external servers (instead of from the local disk). You can design stunning interactive components with tools like Framer, then import them to your Nex.js app without harming your website’s speed.

2. Implement placeholder content

Server-Side Rendering comes with a challenge for developers when Implementing placeholder content because your page and its data are coming from the server using the getServerSideProps function.

The solution for this is to create a static page that displays the page’s structure that shows the data as if it’s loading. Like this:

Then redirect your user to your server-side rendered page:

NB: NextJS now supports placeholder You can check this question on StackOverFlow

<Image 
src={image}
placeholder="blur"
blurDataURL={blurDataURL}
width="100%"
height="100%"
/>

3. Use CSR for high accuracy

This method is ideal for high accuracy data levels like dashboards, reporting, authentication forms, product pricing, as well as pages that are interactive and contain critical values that cannot be outdated.

I normally use this method if I need to see the latest data every time I access the page.

However, the accuracy data level comes at the cost of SEO; the data is not visible in the page source during the initial load and requires the search engine crawler to work harder. For those reasons, the load time is slower because it happens in the client browser.

4. Use SSR for accuracy and SEO

This is ideal for applications and websites that require high data accuracy and a good SEO score, like product pages, comment sections, and for those sites that have lots of products with details that are regularly updated.

However, high data accuracy and SEO friendliness come at a price.

SSR can cause some latency issues; the rendering happens in the server when the request for that page is made before it is sent to the browser. Latency is the time that takes for the request to go to the server and back.

5. Use SSG for a more permanent content

SSG is ideal for data that doesn’t change often, like blog posts on sites that have few products or details that are not updated often, profile pages — anything that shows information that isn’t critical.

Low data accuracy makes the latency issues disappear, as the data rendering is done at build time and cached in the CDNs close to the users.

6. Use ISR for a combined approach

ISR (a relatively new technique which is a combination of SSG and SSR) is ideal for blogs built using a CMS; it allows the content to be updated without having to rebuild the whole site (like for SSG). ISR fetches the latest changes when visiting the page ready for the second visit. This data fetching technique is a hybrid between load time and data accuracy, as the rendering and caching are done at intervals.

It’s worth keeping in mind that, once changes are applied, you will need to wait a few seconds and then refresh the page twice to see the changes.

Conclusion

Web applications built with Next.js are performant by default, but to stay fast, you can use the help of Next.js Analytics. You should be constantly taking care of performance because probably your sites will grow over time and become more complex as developers add new features and enhancements.

Read More:

--

--

Ala Ben Aicha
Ala Ben Aicha

Written by Ala Ben Aicha

Freelance Full Stack JS Developer (React, Node, React-Native)

Responses (1)