Next.js
About Next.js
Next.js is a flexible React framework that helps you to build fast and modern applications. It can be used to solve some application requirements such as:
- Routing
- Data Fetching
- Integrations
Next.js allows you to use static-generation on a per-page basis, through Incremental Static Regeneration (ISR), without having to rebuild the entire application. That means you can enjoy the benefits of static and still be able to scale.
A page, in Next.js, is a React Component inside a file. This file can be in any of the following extensions:
.js
.jsx
.ts
.tsx
Every page has an associated route based on its file name.
Example:
Let’s say you create pages/azion.js
exporting a React component.
export default function Azion() {
return <div>The easiest way to build, deliver, observe and secure modern applications.</div>
}
The page will be accessible at /azion
:
pages/
azion.js
Pre-rendering
Next.js generates HTML for each page in advance, relieving client-side Javascript of this burden. As a consequence, this pre-rendering can help your application have a better performance and Search Engine Optimization (SEO).
Pre-rendering forms
- Static Generation: during build time, the HTML is generated and reused on each request.
- Server-side Rendering: the HTML is generated on each request.
Static HTML Export
You can export your Next.js application to static HTML, which doesn’t need a Node.js server for rendering.
To use next export
, you have to update your build script in your package.json
file:
"scripts": {
"build": "next build && next export"
}
To dive deeper into the Next.js world, read the Next.js documentation
Azion and Next.js
To create a Next.js application on the Azion Platform you need:
- An Amazon S3 bucket on Amazon Web Services (AWS) with write and read permissions.
- An account on the Azion platform with Edge Functions enabled.
- The Node.js runtime environment, version 16.x or higher, installed in a build environment.
- The latest Azion CLI version installed.
See how to have a Next.js project up and running on the Azion platform on Creating a function on Azion using the Next.js framework.
Note: currently, only Static HTML Export Next.js use cases are supported by the Azion Platform.