Open In App

How to Deploy JavaScript Apps with Netlify ?

Last Updated : 02 Apr, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Deploying a JavaScript Application on Netlify is easy. You just need to run a few commands in your computer’s command prompt. Netlify works well with Git, so whenever you make changes to your code and push them to your Git repository, Netlify automatically updates your deployed app.

The below methods can be used to deploy JavaScript apps with Netlify:

Using Drag and Drop

You can drag and drop the project folder of the JavaScript project to deploy it with Netlify by following the below steps.

Step 1: Create a project folder

Create a folder to put the project application inside that folder. It becomes easy to drag and drop the folder to build and make it deployed. Netlify has feature to analyse project and make that deployed.

Step 2: Create utility files

Create two files, One for HTML page(index.js) and one for JavaScript application code(script.js).

Screenshot-2024-03-21-164553

Step 3: A Sample JavaScript Application

It is a simple even-odd number checker application. It contains basic HTML code with a HTML form, label, input box, and a submit button. JavaScript code cotains logic to identify the number and check whether it is Even or Odd, and according to it, alerting the result on submit

HTML
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" 
          content="width=device-width, initial-scale=1.0">
    <title>Even or Odd Checker</title>
</head>

<body>
    <h1>Even or Odd Checker</h1>
    <form id="numberForm">
        <label for="numberInput">
              Enter a number:
          </label>
        <input type="number" id="numberInput" required>
        <button type="submit">Submit</button>
    </form>
    <!-- Linking script file-->
    <script src="script.js">
    </script>
</body>

</html>
JavaScript
// JavaScript code to check if a number is even or odd
document.getElementById('numberForm')
    .addEventListener('submit', function (event) {
    event.preventDefault();

    // Get the input value
    const number = 
        parseInt(document.getElementById('numberInput').value);

    // Check if the number is even or odd
    if (number % 2 === 0) {
        alert(number + ' is even.');
    } else {
        alert(number + ' is odd.');
    }
});

Step 4: Open Netlify and login

Open Netlify, Login in it via signup or directly through github or gmail.

Step 5: Open sites tab

Go to Sites tab in the left sidebar just below the team overview tab.

Step 6: Navigate to ‘add new site’ and select Deploy manually.

Now, select the add new site tab in the right and then select the Deploy manually option from the dropdown.

rec-ezgifcom-video-to-gif-converter

Step 7: Drag and Drop the created project folder

After uploading project folder by drag and drop, Netlify build it and provide a live link of application. In this way, a JavaScript application can be deployed by just drag and drop. Below is the Output GIF.

Deployed project Output:

rec1-ezgifcom-video-to-gif-converter

Steps to deploy JavaScript application using Git repository

Netlify offers seamless integration with Git repositories (GitHub, GitLab, Bitbucket) for continuous deployment. When changes are pushed to the repository, Netlify automatically triggers a build and deploys the updated app.

Step 1: Create a project

Create a project with any number of required files. You can also use the example project used in the previous approach.

Step 2: Create a GitHub repository

Open your GitHub account and create a new repository for your project. Name the repository anything you want, for example, My project. Upload project files to github and commit.

0318-ezgifcom-video-to-gif-converter

Step 3: Setting up Netlify

Create a Netlify account (if you have not any). Now, connect your GitHub account with Netlify. Authorize Netlify to use GitHub to access your repositories.

Step 4: Go to the Sites section

Select the Sites option from the left sidebar. It is the entry point to deploy any application with different approaches.

Screenshot-2024-03-26-144817

Sites in Navigation bar in Netlify account


Step 5: Click on Add new site

Click the add new site button. It provides three methods to deploy the web application.

Screenshot-2024-03-26-145016Step 6: Select import an existing project

Choose the import an existing project from the dropdown to deploy a Github app on Netlify.

Screenshot-2024-03-26-145547

Step 7: Select Deploy with GitHub

Choose Deploy with Github as the application code available on Github. If the application code is on another platform then choose accordingly.

Screenshot-2024-03-26-150043

Step 8: Select project to be deployed

After connecting to Github, all the github repositories will be listed down, choose the repository which contains the web application code.

Screenshot-2024-03-26-150142

Step 9: Give website name

After choosing Application repository, provide the site name, and leaving other thing as it is.

Screenshot-2024-03-26-150425

Step 10: Deploy Application

After clicking the Deploy site button, it redirect us to deployment page, and in this way, the JavaScript application becomes live.

Screenshot-2024-03-26-150527

Deployment using netlify-cli

Using the GitHub repository is not the only way to deploy a JavaScript App on Netlify, this can also be done by using Netlify CLI (Command Line Interface).

Step 1: Install netlify-cli dependency in your project.

This dependency helps us to deploy our application directly from CLI and provide deployed URL.

npm install netlify-cli -g

Step 2: Initialize netlify in your project.

If the netlify account is logged in, it show the team and here we can set site name. As soon as we add site name, hit enter, then netlify cli detect project structure and files and finally provide site URL.

Screenshot-2024-03-18-235612

Step 3: Run netlify deploy

This command will compile all files of project application, asking for publish directory, and Netlify starts building the deployed link for application.

Screenshot-2024-03-19-001135

Screenshot-2024-03-19-001157

Step 4: Navigate to the created link

After deployment, we have JavaScript application live, and anyone can access that project through link.

ty-ezgifcom-video-to-gif-converter



Similar Reads

How to deploy simple frontend server-less (static) React applications on Netlify
Netlify is one of the most popular hosting services that specialize in hosting server-less services for web applications and static websites. It is a web development program that quadruples productivity. By unifying the elements of the modern decoupled web, from local development to advanced edge logic, Netlify enables a faster path to much more pe
5 min read
How to Deploy website on Netlify ?
You have your website ready and don't know how to reach the audience. Most of us coders create amazing websites using HTML, CSS, and JavaScript and just save them locally or on remote host services like GitHub and BitBucket. Now, what if you need non-programmers to view your work? This is why it becomes too important to deploy your web application
2 min read
How to Deploy React App on Netlify Using Github?
React App is a web or mobile application that is built using the React library of JavaScript. It helps users create interactive, single-page, and dynamic applications. These applications are built using HTML, CSS, and JavaScript. Deployment of a React app can be done via GitHub, Netlify, or any other deployment platform. GitHub has its gh-pages, wh
6 min read
How to deploy Node.js app on Netlify ?
Netlify is a powerful platform that simplifies the process of deploying and managing web projects. It provides a wide range of features, including continuous deployment, automatic SSL, serverless functions, form handling, and much more. With Netlify, you can deploy static sites, single-page applications (SPAs), and server-side applications with eas
3 min read
How to Deploy ExpressJS on Netlify ?
This guide explores the process of deploying an Express.js application on Netlify, a popular platform known for hosting web projects with ease. From understanding the basics of Express.js to configuring serverless functions on Netlify, this comprehensive guide offers step-by-step instructions in simple English, making the deployment process accessi
5 min read
How to deploy PHP apps into Cloud ?
PHP is a server-side scripting language that can be used for developing web applications or websites. In this article, we will see how to deploy the PHP applications in the Cloud. To deploy PHP apps on the cloud, we can use any cloud service provider. Here, we will be using the AWS EC2 Instance based on Ubuntu 18.04 LTS. Below are the required step
3 min read
How to Deploy React App using Azure Static Web Apps ?
Microsoft Azure is a public cloud computing platform. It provides a lot of cloud services to access, manage, and deploy applications. Where as Azure Static Web App is one of the services of Microsoft Azure. It automatically builds and deploys full-stack web apps from the code repository to azure. In this article, we will learn how to deploy React a
3 min read
How to use Azure Static Web Apps to Deploy an Angular App ?
In this article, we will learn how to deploy Angular applications using Azure Static Web Apps. Microsoft Azure: Microsoft Azure is a public cloud computing platform. It provides a lot of cloud services to access, manage, and deploy applications. Azure Static Web Apps: Azure Static Web App is one of the services of Microsoft Azure. It automatically
3 min read
Difference between Native Apps and Web Apps
Native Apps: Native apps are installed onto the device itself and are developed especially for a particular operating system. These apps are available on app stores such as Apple App Store, Google Play Store, etc. Native apps work in specific operating systems such as Apple iOS, Android or Windows. If an is app made for Android then it will not wor
4 min read
What are the advantages of native apps over hybrid apps ?
Native apps are better than hybrid apps because they provide features reserved exclusively for the OS(operating system) and their execution time (runtime) and responsiveness (runtime) are superior to hybrid apps. A major advantage of native applications is that they provide the best user experience and performance. What are Native apps:Native apps
3 min read