Skip to main content

Build and push assets Next.JS

In this section, we explain how nullplatform supports the process of building and pushing Next.JS applications.

Most Next.JS applications are packaged into .js and .css files, which are then distributed as static assets. As such, any runtime environment variables must be included in the packaged application during the CI pipeline.

Partial Support

The nullplatform parameters services cannot be utilized for Next.JS applications, as they are inserted at runtime after the application has been packaged and stored as static files.

Building for Multiple Environments If your application requires different configurations for various environments (e.g., development, staging, production), you will need to create a separate build for each environment and configure your CI pipeline to inject the correct environment variables into each build.

There are two primary strategies to achieve this: Branch per Environment or Multi-Asset Builds.

Branch per Environment In this approach, you should create a separate branch for each environment you intend to support. When a commit is pushed to one of these specific branches, your CI pipeline must package the application with the corresponding environment configurations.

Common practices include using the master or main branch for production builds, and stage or dev branches for pre-production environments.

By following this strategy, you will have a distinct build for each environment. It is advisable to implement a versioning strategy that clearly identifies the target environment of each release.

Making Your Builds Distinguishable in Nullplatform

You can specify the --name argument when using the np asset push command in the nullplatform CLI.

By assigning a unique asset name for each environment, nullplatform will help prevent deploying the wrong asset to an incorrect environment.

Multi-Asset Builds An alternative approach is to maintain a single branch where the CI pipeline builds an asset for each environment.

In this scenario, you will have a single build, and the appropriate asset will be selected during the deployment process.

Pushing Multiple Assets

When pushing multiple assets, you must specify the --name argument in the np asset push command of the nullplatform CLI.