How to Use GitHub Copilot to Code a Web App in 2 Hours
How to Use GitHub Copilot to Code a Web App in 2 Hours
Building a web app can feel like a daunting task, especially if you're a solo founder or indie hacker. You might be staring at a blank screen, unsure of where to start, or overwhelmed by the endless lines of code. But what if I told you that you could leverage AI to speed up the process significantly? Enter GitHub Copilot, a tool that can help you code faster and more efficiently. In this guide, I'll walk you through how to use GitHub Copilot to build a simple web app in just 2 hours.
Prerequisites
Before we dive in, here’s what you’ll need:
- GitHub Account: Sign up for free if you don’t have one.
- Visual Studio Code (VSCode): Download and install it from the official site.
- GitHub Copilot Subscription: As of August 2026, Copilot is priced at $10/month for individuals and $19/month for teams.
- Basic Understanding of JavaScript and HTML: Familiarity with these languages will help you leverage Copilot effectively.
Step 1: Set Up Your Environment
-
Install GitHub Copilot in VSCode:
- Open VSCode.
- Go to Extensions (Ctrl+Shift+X) and search for "GitHub Copilot."
- Click "Install" and follow the prompts to authenticate your GitHub account.
-
Create a New Project:
- Open the terminal in VSCode (Ctrl+`).
- Run
mkdir my-web-app && cd my-web-appto create a new directory. - Initialize a new Node.js project with
npm init -y.
-
Install Necessary Packages:
- For a simple web app, you might want to use Express. Install it using:
npm install express
- For a simple web app, you might want to use Express. Install it using:
Step 2: Start Coding with GitHub Copilot
Now that your environment is set up, let’s start coding. Here’s how you can leverage Copilot effectively:
-
Create an
index.jsFile:- In your project folder, create a file named
index.js. - Start typing the code for a basic Express server. For example, type
const express = require('express');and watch Copilot suggest the rest.
- In your project folder, create a file named
-
Build the Server:
- Type
const app = express();and thenapp.get('/', (req, res) => {and see how Copilot suggests the response code. - You might end up with something like this:
const express = require('express'); const app = express(); app.get('/', (req, res) => { res.send('Hello, World!'); }); app.listen(3000, () => { console.log('Server is running on http://localhost:3000'); });
- Type
-
Add More Features:
- Want to add a new route? Just start typing
app.get('/about', (req, res) => {and see what Copilot suggests. - You can easily build out your app with various endpoints and features by simply describing what you want in comments, and Copilot will generate the code for you.
- Want to add a new route? Just start typing
Step 3: Test Your Web App
-
Run Your Server:
- In the terminal, run
node index.js. - Open your browser and navigate to
http://localhost:3000to see the "Hello, World!" message.
- In the terminal, run
-
Debugging with Copilot:
- If you encounter any issues, you can describe the problem in comments, and Copilot can suggest potential fixes.
- For example, if you're having trouble with routes, you might comment,
// Fix route handlingand see what Copilot comes up with.
Troubleshooting Common Issues
- Copilot Not Suggesting Code: Make sure you’re connected to the internet and that your subscription is active. Sometimes, simply restarting VSCode can solve this issue.
- Incorrect Suggestions: Always review and test the code that Copilot generates. It’s not perfect and might suggest outdated or incorrect patterns.
What’s Next?
Now that you’ve built a simple web app using GitHub Copilot, consider expanding its functionality. Add a front-end framework like React or Vue.js to enhance the user experience. You could also integrate a database like MongoDB for persistent data storage.
Pricing Breakdown
| Tool | Pricing | Best For | Limitations | Our Take | |-------------------------|-------------------------|-------------------------------------|----------------------------------------|----------------------------------------| | GitHub Copilot | $10/mo (individual) | Rapid coding assistance | Can suggest incorrect code | We use it for quick prototypes | | Visual Studio Code | Free | Code editing and debugging | Requires extensions for advanced features | Essential tool for our workflow | | Express | Free | Building server-side applications | Not suitable for large-scale apps | Perfect for lightweight web servers | | MongoDB | Free tier + $25/mo | NoSQL database for web apps | Free tier has limited capacity | Great for projects of all sizes |
Conclusion
Using GitHub Copilot can drastically reduce the time it takes to build a web app, and with just a couple of hours, you can have a functional prototype up and running. Start by setting up your environment, leveraging Copilot for coding, and testing your app.
If you're feeling stuck, remember that Copilot is a tool meant to assist you, not replace your coding skills. So, go ahead, experiment, and build something great!
Follow Our Building Journey
Weekly podcast episodes on tools we're testing, products we're shipping, and lessons from building in public.