Ai Coding Tools

How to Build an AI-Powered Web App Using Cursor in 2 Hours

By BTW Team4 min read

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

In short

Step-by-step tutorial on building your first AI-powered web application with Cursor, designed for those with minimal coding experience.

Building an AI-powered web app sounds daunting, especially if you're just getting started. But what if I told you it could be done in about two hours? With Cursor, a tool designed specifically for coding assistance, you can streamline the development process and get your project off the ground without the usual headaches. In this guide, I'll walk you through the essentials of using Cursor to build your first AI web app, sharing real experiences and some honest trade-offs along the way.

Prerequisites

Before diving in, here’s what you need to get started:

  • A computer with internet access: This is a given, but make sure it's a machine you can use comfortably for a couple of hours.
  • Cursor installed: Download and install Cursor from Cursor's website (Free to start).
  • Basic understanding of JavaScript: While you don’t need to be a pro, knowing the basics will help you navigate the code.
  • An idea for your app: Think of a simple concept, like a to-do list or a weather app.

Step-by-Step Guide to Building Your Web App

Step 1: Set Up Your Project (15 minutes)

  1. Create a new directory: Open your terminal and run:

    mkdir my-ai-app
    cd my-ai-app
    
  2. Initialize a Node.js project:

    npm init -y
    
  3. Install necessary packages: You’ll need Express for your server and any AI library you plan to use (like OpenAI's API).

    npm install express axios dotenv
    
  4. Create essential files:

    touch index.js .env
    

Step 2: Write Your Server Code (30 minutes)

Here’s where Cursor shines. Open index.js and start coding your server. Use Cursor to generate boilerplate code. For example, you can type “create a simple Express server” and let Cursor fill in the details.

Expected output:

const express = require('express');
const axios = require('axios');
require('dotenv').config();

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 port ${PORT}`);
});

Step 3: Integrate AI Functionality (30 minutes)

  1. Set up your .env file: Add your API keys here.

    OPENAI_API_KEY=your_api_key
    
  2. Add AI endpoint: Use Cursor to generate a simple endpoint that interacts with the OpenAI API. For instance:

app.post('/api/ai', async (req, res) => {
    const response = await axios.post('https://api.openai.com/v1/engines/davinci/completions', {
        prompt: req.body.prompt,
        max_tokens: 100
    }, {
        headers: {
            'Authorization': `Bearer ${process.env.OPENAI_API_KEY}`
        }
    });

    res.send(response.data);
});

Step 4: Test Your Web App (30 minutes)

  1. Run your server:

    node index.js
    
  2. Use Postman or similar tool to test your API: Send a POST request to http://localhost:3000/api/ai with a JSON body like:

    {
        "prompt": "What is the weather like today?"
    }
    
  3. Check responses: Make sure the AI is returning meaningful responses.

Step 5: Deploy Your App (30 minutes)

  1. Choose a hosting platform: Vercel and Heroku are great for beginners.

    • Vercel: Free tier available; ideal for static sites and serverless functions.
    • Heroku: Free tier + easy deployment for Node apps.
  2. Follow their deployment instructions: Both platforms have straightforward guides.

Troubleshooting Common Issues

  • Server not starting: Check for syntax errors in your code. Cursor can help identify those.
  • API requests failing: Ensure your API key is correct and that you're hitting the right endpoint.
  • CORS issues: If you're calling the API from the front end, you might need to handle CORS.

What's Next?

Now that you have your basic AI web app up and running, consider expanding its functionality. You could integrate user authentication, add a frontend with React, or even explore more advanced AI features.

If you’re looking for inspiration, listen to episode 32 of Built This Week where we discuss how we scaled our AI app from an MVP to a fully-featured product.

Conclusion

Building an AI-powered web app using Cursor can be done in just two hours if you have a clear idea and follow these steps. Cursor simplifies coding and helps you get past the initial hurdles. Start with a simple project, and once you’re comfortable, expand your horizons.

What We Actually Use

In our experience, we use Cursor for quick prototyping and AI integrations. For hosting, we often choose Vercel for its simplicity and speed. If you need a more robust solution, Heroku is also solid, but it’s slightly more complex.

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