The Azion Next.js Static Boilerplate enables the creation and deployment of a Next.js Single-Page Application (SPA) directly on the edge of the network. By executing the boilerplate, several steps are automated, from repository management to edge deployment.
This template uses Next.js version
About static exportsSection titled About static exports
The core of Next.js supports static exports. This allows you to initiate your project either as a static site or a SPA and then add features that require a server. By using these advanced features, Next.js generates one HTML file per route, breaking a strict SPA into individual HTML files, and your project can be deployed and hosted on any web server that can serve HTML/CSS/JS static assets.
This capability includes supported and unsupported features, listed below, which you must take into account when developing and managing your project.
Go to Next.js documentation for more details on Static exports.
Supported featuresSection titled Supported features
- Server components
- Client components
- Image optimization
- Image optimization (through
next/imagecan be used with a static export by defining a custom image loader in
- Route handlers
- Browser APIs
Unsupported featuresSection titled Unsupported features
These features require a Node.js server or dynamic logic that can’t be computed during the build process and aren’t supported:
- Dynamic routes with
- Dynamic routes without
- Route handlers that rely on request
- Incremental static regeneration
- Image optimization (with the default loader)
- Draft mode
RequirementsSection titled Requirements
To use this template, you must activate:
You need to activate this module via Real-Time Manager (RTM). To do so:
- Access Real-Time Manager (RTM) > Account menu
- Select the Billing & Subscriptions option.
- Select the Subscriptions tab.
- Activate the switch for the module.
Getting the templateSection titled Getting the template
To start using the Next.js Static Boilerplate, access Real-Time Manager (RTM) and select the Start with a template option on the homepage.
This will open a new page where you can select the Next.js Static Boilerplate card.
Setting up the templateSection titled Setting up the template
In the configuration form, you must provide the information to configure your Next.js application. Fill in the presented fields.
Fields identified with an asterisk are mandatory.
- Application Name *: the name of your edge application. It’s used to identify and manage your application within Azion’s platform.
- Use a unique and easy-to-remember name. If the name has already been used, the platform returns an error message.
- GitHub Personal Token *: your GitHub personal token.
After completing all the information, click the Next button, located in the bottom-right corner. This will start the deployment process.
Deploying the templateSection titled Deploying the template
You’ll be able to follow the deployment process through a window showing off the logs. When it’s complete, the deployment page appears, confirming the edge application has been successfully created.
This page shows you the following sections:
- Access your Edge Application section includes the link to visit and explore your edge application.
- Build Summary contains the application’s name and function.
- The Deployment details tab can be opened to access the logs related to the deployment.
- What do you want to do next? provides recommendations regarding advanced options to enhance your edge application: Customize Domain, Manage Edge Application, View Edge Application Metrics, View Edge Application Logs, and the Back to Home button.
Key configurationsSection titled Key configurations
The application undergoes an optimized build process, emphasizing optimal performance and efficiency, employing Azion Edge Platform resources.
The script creates a GitHub repository to manage the source code and then it installs all required dependencies. Besides that, your application is deployed on Azion’s platform and while carrying out multiple configurations, such as setting up the edge application and its domain to host your Next.js project and an edge function for custom logic.
The script also commits deployment details to the user’s GitHub repository to maintain a transparent and trackable deployment history, including information related to the version deployed and the timestamp of the deployment.
If you want to know more on how to edit and customize your project’s settings, go to the Managing the template section.
Managing the templateSection titled Managing the template
Considering that this initial setup may not be optimal for your specific edge application, all settings can be customized any time you need by using Azion Real-Time Manager (RTM).
To manage and edit your edge application’s settings, follow these steps:
- Access RTM.
- On the upper-left corner, select Products menu > Edge Application.
- You’ll be redirected to the Edge Application page. It lists all the edge applications you’ve created.
- Find the edge application related to the Next.js Static Boilerplate and select it.
- The list is organized alphabetically. You can also use the search bar located in the upper-left corner of the list; currently, it filters only by Application Name.
After selecting the edge application you’ll work on, you’ll be directed to a page containing all the settings you can configure.
Continuous deploymentSection titled Continuous deployment
Once the template is deployed, you can also edit and update your args and code, as well as implement a continuous deployment workflow. However, you’ll need first to declare secrets on your project’s GitHub repository to complete the second build with the changes. When the second build is completed, you’ll be able to manage your project with a continuous deployment workflow and edit the args as desired.
To do so, open your new Next.js Static Boilerplate repository on GitHub. Then, go to Settings > Secrets and variables > Action to add your variables, following these instructions:
- Add the Azion personal token to the secrets:
- Read how to generate an Azion personal token in the documentation.
- Add the environments for use in the action workflow in the main.yml file, included in the .github/workflows folder of your repository:
- Open a pull request to merge the changes to the main branch and start the automatic deployment.
Now, your project is ready to work with a continuous deployment workflow, updating instantly any changes in the application or the repository.
Adding a custom domainSection titled Adding a custom domain
The edge application created during the deployment has an assigned Azion domain to make it accessible through the browser. The domain has the following format:
xxxxxxxxxx.map.azionedge.net. However, you can add a custom domain for users to access your edge application through it.
Watch the video guide on Next.js Static Boilerplate available on Azion’s YouTube channel: