Netlify is a popular static site hosting serverless platform. It is a popular way to build, deploy, and scale modern web applications in a much more scalable and secure way.
Netlify helps developers to launch websites and campaigns in minutes with no fuss. Netlify is built primarily for JAMstack sites, which unify JavaScript and APIs to allow applications that are well suited for both developers and content editors.
In this tutorial, you will see how to deploy a simple Redis caching app built with Next.js and TailwindCSS to Netlify in 5 minutes.
Visit https://redis.io/try-free to create a free Redis Cloud account. Enable the “RediSearch” module while you create the Redis Enterprise Cloud database. You'll be presented with a database endpoint URL and password. Save it for future reference.
Netlify’s command line interface (CLI) lets you configure continuous deployment directly from the command line. Run the below command to install Netlify CLI on your local laptop:
npm install netlify-cli -g
Verify if Netlify is installed or not by running the below command:
netlify version
netlify-cli/8.15.3 darwin-x64 node-v14.17.3
git clone https://github.com/redis-developer/nextjs-redis-netlify
To authenticate and obtain an access token using the command line, run the following command to login to your Netlify account:
netlify login
This will open a browser window, asking you to log in with Netlify and grant access to Netlify CLI. Once you authenticate, it will ask you to close the window and display the below results:
The netlify init
command allows you to configure continuous deployment for a new or existing site. It will also allow you to create netlify.toml file if it doesn't exists.
The above step creates a netlify.toml
file with the following content
[build]
command = "npm run build"
publish = ".next"
[[plugins]]
package = "@netlify/plugin-nextjs"
As instructed by Netlify, run the below commands to push the latest changes to GitHub:
git add .
git commit -m “Pushing the latest changes”
git push
netlify open --admin
Click "Trigger deploy" to deploy the site
Click on the deploy URL and you should be able to access the app as shown:
Already logged in via netlify config on your machine
Run netlify status for account details
To see all available commands run: netlify help
netlify init
? What would you like to do? + Create & configure a new site
? Team: Redis
Choose a unique site name (e.g. super-cool-site-by-redisdeveloper.netlify.app) or leave it blank for a random name. You can update the site name later.
? Site name (optional): undefined
Site Created
Admin URL: https://app.netlify.com/sites/super-cool-site-by-redisdeveloper
URL: https://super-cool-site-by-redisdeveloper.netlify.app
Site ID: a70bcfb7-b7b1-4fdd-be8b-5eb3b5dbd404
Linked to super-cool-site-by-redis-developer in /Users/redisdeveloper/projects/netlify/basic-caching-demo-nodejs/.netlify/state.json
? Your build command (hugo build/yarn run build/etc): yarn start
? Directory to deploy (blank for current dir): dist
? Netlify functions folder: functions
Adding deploy key to repository...
Deploy key added!
Creating Netlify GitHub Notification Hooks...
Netlify Notification Hooks configured!
Success! Netlify CI/CD Configured!
This site is now configured to automatically deploy from github branches & pull requests
Next steps:
git push Push to your git repository to trigger new site builds
netlify open Open the Netlify admin URL of your site