Building and deploying a simple web application is an exciting way to learn the basics of web development. This guide provides a step-by-step process for creating a minimal web application and deploying it to a hosting service. We'll use HTML, CSS, and JavaScript for the frontend, and we'll deploy our application on a cloud platform.
Before you start, ensure you have the following:
- A text editor (e.g., Visual Studio Code, Sublime Text)
- Basic knowledge of HTML, CSS, and JavaScript
- Node.js and npm installed on your machine
-
Create a Project Directory: Open your terminal and create a new directory for your project.
mkdir simple-web-app cd simple-web-app
-
Initialize npm: Initialize npm in your project directory.
npm init -y
This will create a
package.json
file.
-
Create HTML File: Create an
index.html
file in your project directory and add basic HTML structure.<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Simple Web App</title> <link rel="stylesheet" href="styles.css"> </head> <body> <h1>Hello, World!</h1> <script src="app.js"></script> </body> </html>
-
Create CSS File: Create a
styles.css
file in the same directory.body { font-family: Arial, sans-serif; text-align: center; } h1 { color: #3498db; }
-
Create JavaScript File: Create an
app.js
file in the same directory.console.log('Hello from app.js!');
- Open in Browser:
Open your
index.html
file in a web browser to ensure everything is rendering correctly.
-
Create a GitHub Repository: Create a new repository on GitHub for your project.
-
Push Your Code to GitHub: Push your project to the GitHub repository.
git remote add origin <your-github-repo-url> git branch -M main git push -u origin main
-
Choose a Cloud Platform: Choose a cloud platform for hosting your web application. Options include Heroku, Netlify, or Vercel. We'll be using Netlify for deployment in this tutorial.
-
Create an Account: Create an account on Netlify. You can signin using any of the mentioned methods.
-
Initiating a New Site on Netlify Dashboard: Next, You will be redirected to the Netlify dashboard. Then, click on "New site from Git".
-
Next, choose the repository that you want to deploy and click on the deploy site button.
Next, wait for a few seconds and you will see that it shows you a message with the link to your website.
Congratulations! You've successfully created a simple web application and deployed it to a hosting service.