Ai Coding Tools

How to Use GitHub Copilot to Build a Simple Web App in 2 Hours

By BTW Team3 min read

Comparing tools? See the AI tools tested on the show.

In short

A step-by-step tutorial on leveraging GitHub Copilot to create a simple web application in just 2 hours.

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

  1. Install Node.js: Download and install Node.js from nodejs.org. This will also install npm, which is essential for managing packages.

  2. Set Up VS Code: If you haven’t already, download and install Visual Studio Code from code.visualstudio.com.

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

  1. Create a New Directory: Open your terminal and run:

    mkdir simple-web-app
    cd simple-web-app
    
  2. Initialize the Project: Run:

    npm init -y
    

    This creates a package.json file with default settings.

  3. 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!

  1. Create an index.js file in your project directory:

    touch index.js
    
  2. Start Writing Code: Open index.js in VS Code and type the following comment:

    // Create a simple Express server
    

    Copilot will suggest code snippets for your server setup. Accept the suggestions by hitting the Tab key.

  3. 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}`);
    });
    
  4. Run Your Server: Back in the terminal, run:

    node index.js
    

    Visit http://localhost:3000 in 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.

  1. 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!' });
    });
    
  2. Test the API: Restart your server and visit http://localhost:3000/api/data to 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.

Watch real AI builds every week

Built This Week is a weekly podcast where Jordan Metzner and Sam Nadler build something real with AI every episode, test new AI tools and talk with founders who build with AI.

See the tools

Watch real AI builds every week

Built This Week is a weekly podcast where Jordan Metzner and Sam Nadler build something real with AI every episode, test new AI tools and talk with founders who build with AI.

See the tools
Ai Coding Tools

3 AI Coding Tools That Are Overrated (and Why You Should Avoid Them)

3 AI Coding Tools That Are Overrated (and Why You Should Avoid Them) In the everevolving landscape of AI coding tools, it's easy to get swept up in the hype. As indie hackers and s

Nov 30, 20263 min read
Ai Coding Tools

5 Ways AI Coding Tools Can Accelerate Your MVP Development in 2026

5 Ways AI Coding Tools Can Accelerate Your MVP Development in 2026 In 2026, the landscape for indie hackers and solo founders has evolved significantly, especially with the advent

Nov 26, 20264 min read
Ai Coding Tools

5 AI Coding Tools That Make Legacy Code Feel Brand New in 2026

5 AI Coding Tools That Make Legacy Code Feel Brand New in 2026 If you’re a developer stuck maintaining legacy code, you know the frustration. It’s like navigating a maze blindfolde

Nov 23, 20264 min read
Ai Coding Tools

10 AI Coding Tools That Will Save You Hours of Debugging in 2026

10 AI Coding Tools That Will Save You Hours of Debugging in 2026 Debugging can feel like a neverending cycle of frustration. Whether you're a solo founder or an indie hacker, spend

Nov 18, 20265 min read
Ai Coding Tools

10 Common Mistakes When Using AI Coding Tools for MVP Development

10 Common Mistakes When Using AI Coding Tools for MVP Development As a founder in 2026, you’re likely aware that AI coding tools can significantly speed up the MVP development proc

Nov 16, 20264 min read
Ai Coding Tools

5 AI Coding Myths Every Beginner Developer Should Ditch in 2026

5 AI Coding Myths Every Beginner Developer Should Ditch in 2026 As a beginner developer, you’ve probably come across a ton of buzz surrounding AI coding tools. But with all the hyp

Nov 12, 20263 min read