Templates

Next.js

13min

Next.js is an open-source, React framework, that helps developers build web applications, with all the features you need for production - hybrid static & server rendering, TypeScript support, smart bundling, route pre-fetching, and more.

Microtica offers a ready-to-use template to deploy a Next.js application as part of our Free templates pack. You can deploy a Next.js application on our demo Kubernetes cluster to get started. When ready, you can self-host Next.js on your own AWS account and setup a production-ready solution in minutes.

One-click Deploy

Click Deploy with Microtica below and follow the template steps to deploy your Next.js application on your AWS account.



1. Create an account

Creating a Microtica account is totally free. You can do it by signing up with your email or with your Git account.

2. Select the Next.js template

Microtica Templates Page
Microtica Templates Page


On the left side, you can see a link to the source code of this template. It will redirect you to Microtica's GitHub account.

3. Create Git Repository

As a first step, you need to connect a Git account (GitHub, Bitbucket, GitLab, or CodeCommit). Microtica defines a repository name by default for each template, but you can change it. If you already have a Git account connected to Microtica, you can choose it from the list. We will create a new repository on your account with the provided name, and every Git push will be deployed automatically in Microtica.

Document image


Follow this guide on How to import your existing application in Microtica, if you already have a Node.js application source code.

4. Configure Template

After creating your repository, you need to enter a name for the application, to be able to distinguish it from other apps in the Applications tab.

Configure Template
Configure Template


You can customize this template to meet your requirements with environment variables. You can update the configuration later in App Settings.

5. Select a cluster

The next step is choosing the Kubernetes cluster where your application will deploy. There are three options you can select to run your container app:

  • Create a new EKS cluster on the spot
  • Connect an existing cluster
connect kubernetes cluster


5.1. Create a new EKS cluster on the spot

If you want to deploy your Next.js application on your own AWS account, you can create an AWS managed-Kubernetes (EKS) cluster, by clicking on the Create Amazon EKS Cluster button.

This is the recommended option for production applications, as it gives you full ownership of your cloud infrastructure and applications.

connect AWS account


This action will open the popup shown in the image above. You can select the environment in which you'd want this cluster to be deployed. If you don't have an existing environment, you can create one by selecting the Create Environment action from the dropdown menu.

Once you select an environment, the next step is to select an AWS account and region where the EKS cluster will be deployed. If you don't have a connected AWS account, you can connect one right here by clicking the Connect AWS Account button. This will initiate a CloudFormation stack that will give Microtica permissions to provision infrastructure on your AWS account. Once you create the stack, the connection will be established automatically and you'll be able to see the AWS account in the dropdown list of accounts.

Select the account, select a region, and then click on Continue to move to the deployment of your environment.

Deploying a new Kubernetes cluster on your AWS account could take up to 15 mins.

5.2. Connect an existing cluster

In Microtica you can also connect an existing Kubernetes Cluster that you have and deploy your applications there. You can connect Kubernetes clusters running on basically any cloud provider or on-premise. By connecting a cluster you can use the full capabilities of Microtica’s Kubernetes automation.

To connect an existing Kubernetes cluster in Microtica and deploy your Node.js application there, follow the documentation linked below👇.

6. Deploy the template to your cluster

Once you’re done with the cluster selection, you will see a summary of all the previous steps and what will be deployed with this template.

Deploy the template to your cluster
Deploy the template to your cluster


You can go ahead and trigger a deployment of the environment by clicking on the Deploy button. 

It takes approximately 4-5 minutes (15-20 with EKS) for this application to be deployed on the cloud.

In the meantime, you can follow the detailed deployment logs by clicking the View deployment button if you're deploying an EKS cluster on your AWS account.

Detailed deployment logs in Microtica
Detailed deployment logs in Microtica


When the EKS cluster deployment is finished, or if you're deploying on our Shared Kubernetes cluster, click the View logs button to follow the application deployment.

Foll
Foll


7. Access the application

When the deployment is finished, you will see a View Application button, that leads you to the app Overview tab. Here you can Assign a domain to your application, to be able to access it later. You can use a Microtica-assigned domain which is free, or setup your own custom domain. Follow the steps to complete the exposure of your Next.js app on the Internet. 

Access the application
Access the application


For even more information, you can also look at the Deployments and Monitoring tabs, where you have the pipeline history, resource consumption metrics, and logs for your instances.

To learn more about how to scale your Next.js application in Microtica, read the following article about Scaling Applications in Microtica.

Optimize AWS cost

To save costs while using Next.js in a non-production environment, consider running it from Monday to Friday, 8 hours per day. This schedule can help you achieve at least a 65% reduction in your cloud expenses.

In the Resources or Cost Dashboard, create a Saving Schedule to implement these cost-saving measures.

Document image