How to Use GitHub Copilot to Build a Simple Web App in 2 Hours
How to Use GitHub Copilot to Build a Simple Web App in 2026
If you’ve ever felt overwhelmed staring at a blank code editor, you're not alone. As indie hackers and side project builders, we often deal with the pressure of needing to code efficiently without spending days on trivial tasks. Enter GitHub Copilot, a powerful AI coding assistant that promises to accelerate your development process. In this guide, I’ll show you how to leverage GitHub Copilot to build a simple web app in just 2 hours.
Prerequisites
Before we dive in, here’s what you’ll need:
- GitHub Copilot subscription: $10/month or $100/year.
- A GitHub account: Free.
- Code editor: Visual Studio Code (VS Code) - Free.
- Node.js and npm: Free, necessary for running your web app locally.
- Basic understanding of JavaScript: If you’re familiar with basic programming concepts, you’ll be fine.
Step 1: Set Up Your Environment
-
Install Node.js: Download and install Node.js from nodejs.org. This will also install npm, which is essential for managing packages.
-
Set Up VS Code: If you haven’t already, download and install Visual Studio Code from code.visualstudio.com.
-
Install GitHub Copilot: In VS Code, go to Extensions (Ctrl+Shift+X) and search for "GitHub Copilot." Click “Install” and sign in with your GitHub account.
Step 2: Create Your Web App
-
Create a New Directory: Open your terminal and run:
mkdir simple-web-app cd simple-web-app -
Initialize the Project: Run:
npm init -yThis creates a
package.jsonfile with default settings. -
Install Express: We’ll use Express.js for our web server:
npm install express
Step 3: Write Code with GitHub Copilot
Now comes the fun part—coding with Copilot!
-
Create an
index.jsfile in your project directory:touch index.js -
Start Writing Code: Open
index.jsin VS Code and type the following comment:// Create a simple Express serverCopilot will suggest code snippets for your server setup. Accept the suggestions by hitting the Tab key.
-
Basic Server Setup: Your code should look something like this:
const express = require('express'); const app = express(); const PORT = process.env.PORT || 3000; app.get('/', (req, res) => { res.send('Hello World!'); }); app.listen(PORT, () => { console.log(`Server is running on http://localhost:${PORT}`); }); -
Run Your Server: Back in the terminal, run:
node index.jsVisit
http://localhost:3000in your browser, and you should see "Hello World!"
Step 4: Add More Features
To enhance your web app, let’s add a simple route that returns JSON data.
-
Add the Route: In
index.js, add a new route:// API endpoint to fetch data app.get('/api/data', (req, res) => { res.json({ message: 'This is your data!' }); }); -
Test the API: Restart your server and visit
http://localhost:3000/api/datato see the JSON response.
Troubleshooting: What Could Go Wrong
- Copilot Suggesting Incorrect Code: Sometimes, Copilot might suggest outdated or incorrect code. Always double-check its suggestions.
- Server Not Starting: Ensure that you have installed all necessary packages and that you are running the correct command in your terminal.
What's Next
With your basic web app up and running, consider expanding it by adding a frontend framework like React or Vue.js. You could also deploy it using services like Vercel or Heroku, which are both cost-effective options for indie projects.
Conclusion
Using GitHub Copilot can significantly speed up your development process, allowing you to focus on building rather than getting stuck on syntax. If you follow the steps outlined above, you can have a functional web app in about 2 hours.
Start Here: If you’re looking to dive deeper into AI coding tools and their practical applications, make sure to check out our weekly podcast, Built This Week, where we discuss tools we’ve tested, products we’re shipping, and lessons learned from building in public.
Follow Our Building Journey
Weekly podcast episodes on tools we're testing, products we're shipping, and lessons from building in public.