DZone
Database Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Database Zone > How to Deploy a Simple Redis Caching App Built With Next.js and TailwindCSS to Netlify in 5 Minutes

How to Deploy a Simple Redis Caching App Built With Next.js and TailwindCSS to Netlify in 5 Minutes

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.

Ajeet Raina user avatar by
Ajeet Raina
·
May. 03, 22 · Database Zone · Tutorial
Like (2)
Save
Tweet
3.08K Views

Join the DZone community and get the full member experience.

Join For Free

Netlify is a popular static site hosting serverless platform. It is a popular way to build, deploy, and scale modern web applications to be more scalable and secure.

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.

netlify

Features of Netlify

  • It delivers out-of-the-box continuous integration.
  • The platform allows continuous deployment through its support for Git repository deployment.
  • It allows developers to focus on building and deploying apps by abstracting all the maintenance work away from the developers.
  • The platform provides free SSL, CDN, and continuous integration.
  • It has built-in DNS management & SSL certificates.

How Does Netlify Work?

netlify

  1. The developer writes code and stores it in a version control repository (e.g., GitHub).
  2. When a new change is merged into the main repository branch, a webhook notifies Netlify to deploy a new site.
  3. Netlify pulls the latest version of the app from the repository and runs a build command to generate the static site files.
  4. Netlify then uses Plugins and internal code to make adjustments to your site, pre-render all of your pages in static HTML, and improve it further /
  5. Once the build process gets completed, Netlify takes the static assets and pushes them to its global CDN for fast delivery.

This tutorial will show how to deploy a simple Redis caching app built with Next.js and TailwindCSS to Netlify in 5 minutes.

Step 1. Setup a Free Redis Enterprise Cloud account

Visit https://developer.redis.com/create/rediscloud/ and create a free Redis Enterprise Cloud account. Next, enable the “RediSearch” module while creating the Redis Enterprise Cloud database. Once you complete the tutorial, you will be provided with the database Endpoint URL and password. Save it for future reference.

Step 2. Install Netlify CLI

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:

JavaScript
 
npm install netlify-cli -g


Verify if Netlify is installed or not by running the below command:

Shell
 
netlify version 
netlify-cli/8.15.3 darwin-x64 node-v14.17.3

Step 3. Clone the Repository

Shell
 
git clone https://github.com/redis-developer/nextjs-redis-netlify

Step 4. Login to Netlify via CLI

To authenticate and obtain an access token using the command line, run the following command to log in to your Netlify account:

 
Shell
 
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.

Step 5. Configure Continuous Deployment

The netlify init the 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 exist.


Shell
 
netlify init 


Shell
 
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


The above step creates a netlify.toml file with the following content

Shell
 
[build]
  command = "npm run build"
  publish = ".next"

[[plugins]]
  package = "@netlify/plugin-nextjs"


Step 6. Pushing the Changes to GitHub

As instructed by Netlify, run the below commands to push the latest changes to GitHub:

Shell
 
git add .
git commit -m “Pushing the latest changes”
git push


Step 7. Open the Netlify Admin URL


Shell
 
netlify open --admin
 

Step 8. Add Environment Variable for Redis Enterprise Cloud

Environment Variable

Step 9. Trigger the deployment#

Click "Trigger deploy" to deploy the site

MyImage1

Step 10. Accessing the App


Click on the deployed URL, and you should be able to access the app as shown:

MyImage


Next.js app Redis (company)

Published at DZone with permission of Ajeet Raina. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Why to Implement GitOps into Your Kubernetes CI/CD Pipelines
  • Top Six Kubernetes Best Practices for Fleet Management
  • Suspicious Sortings in Unity, ASP.NET Core, and More
  • Datafaker: An Alternative to Using Production Data

Comments

Database Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo