Getting StartedSolveBuildIntelligenceLearnHelpWhat's New
RECIPES

AI App

Recipe for building an AI writing assistant in Rocket.new Build with chat UI, saved conversations, streaming responses, and Stripe subscription billing.

An AI writing assistant where users chat with GPT to draft blog posts, edit copy, and brainstorm ideas. The app includes conversation history so users can pick up where they left off, user accounts with authentication, and a Pro subscription tier that unlocks unlimited messaging.

By the end of this recipe you will have a production-ready AI app that you can customize, rebrand, and launch as your own product.

Tech stack

You do not need to understand these technologies. Rocket handles them automatically. This table is for reference.
IntegrationWhat it does
OpenAIGPT models for chat completions and content generation
SupabaseUser authentication, conversation storage, and usage tracking
StripePro subscription billing ($12/month)
ResendWelcome emails and daily usage alerts
NetlifyOne-click deployment to production
Next.js + TypeScriptApp framework with server-side API routes

Architecture overview

Here is how data flows through the app:

  1. Sign in. The user creates an account or logs in through Supabase Auth.
  2. Send a message. The user types a prompt in the chat interface. The message is sent to an API route that calls the OpenAI Chat Completions endpoint.
  3. Stream the response. GPT's response is streamed back to the browser in real time, token by token.
  4. Save the conversation. Each message pair (user + assistant) is saved to a Supabase messages table, grouped by conversation.
  5. Track usage. A counter in Supabase tracks how many messages the user has sent today.
  6. Enforce limits. Free users are capped at 20 messages per day. When they hit the limit, the app shows an upgrade prompt.
  7. Upgrade. Clicking "Upgrade to Pro" redirects to a Stripe Checkout session for the $12/month plan.
  8. Send emails. Resend delivers a welcome email on signup and a daily usage summary for Pro users.

How long does it take?

PhaseWhat you are buildingEstimated time
SetupProject, Supabase, OpenAI5-10 minutes
ChatInterface, streaming, history10-15 minutes
Business logicUsage limits, Pro plan5-10 minutes
CommunicationEmail notifications5 minutes
LaunchDeploy, test, go live5 minutes
TotalComplete AI app30-45 minutes

Step-by-step build

Open rocket.new and describe the app you want to build. Be specific about the core features so Rocket generates a solid foundation.

Build an AI writing assistant called "DraftAI". Users can sign in, start a new chat conversation with GPT, and get help drafting blog posts, editing copy, and brainstorming content ideas. The chat should feel fast and modern with a clean, minimal UI. Use Next.js with TypeScript and Tailwind CSS. Include a sidebar with a list of past conversations and a "New Chat" button.

A detailed initial prompt saves you from reworking the layout later. Include the app name, core features, and UI preferences up front.

Connect Supabase to handle user accounts and store all conversation data. Rocket will create the database tables and auth flow automatically.

Connect Supabase. Set up email/password authentication with a sign-up page, login page, and protected routes. Create these database tables:
- conversations: id, user_id, title, created_at, updated_at
- messages: id, conversation_id, role (user or assistant), content, created_at
- usage: id, user_id, date, message_count
Add row-level security so users can only access their own data.

Add your OpenAI API key so the app can send messages to GPT and receive completions.

Connect OpenAI. Use the GPT-4o model for all chat completions. Add a system prompt that says: "You are DraftAI, a helpful writing assistant. You help users draft blog posts, edit copy, brainstorm ideas, and improve their writing. Be concise, clear, and encouraging. When asked to write content, match the tone the user requests."

Your OpenAI API key is billed separately by OpenAI based on token usage. Monitor your spending in the OpenAI usage dashboard.

Make the chat feel responsive by streaming GPT's responses token by token instead of waiting for the full completion.

Update the chat so that GPT responses stream in real time, word by word. Use the OpenAI streaming API. Show a typing indicator while the response is loading. Each message should display the sender (user or AI) with a subtle avatar. Add a text input at the bottom with a send button and support Enter to send. Auto-scroll to the latest message.

Streaming makes the app feel much faster because users see the first words immediately instead of waiting several seconds for a complete response.

Let users create multiple conversations, switch between them, and pick up past chats where they left off.

Add conversation history. The sidebar should list all past conversations for the logged-in user, sorted by most recent. Clicking a conversation loads its full message history. Add a "New Chat" button at the top of the sidebar that creates a fresh conversation. Auto-generate a short title for each conversation based on the first user message. Add a delete button on each conversation with a confirmation dialog.

Add a daily message cap for free users to control costs and incentivize upgrades.

Add usage tracking. Free users can send up to 20 messages per day. Track the count in the usage table in Supabase, resetting at midnight UTC. Show a small counter in the chat header like "5 of 20 messages used today". When a free user hits 20 messages, disable the input and show a friendly banner that says "You've reached your daily limit. Upgrade to Pro for unlimited messages." with an upgrade button.

Pick a daily limit that gives users enough value to see the product's potential while still creating a reason to upgrade. 20 messages is a good starting point.

Add a paid tier that removes usage limits. Stripe handles the checkout, billing, and subscription management.

Connect Stripe. Create a Pro plan at $12/month. Add a pricing section accessible from the sidebar and from the upgrade banner. The pricing page should show Free vs Pro with a feature comparison: Free: 20 messages/day, basic writing assistance, 5 saved conversations Pro: Unlimited messages, priority responses, unlimited saved conversations, export conversations as Markdown Use Stripe Checkout for payment. After successful payment, update the user's subscription status in Supabase and immediately unlock Pro features. Handle subscription cancellation and show billing status in account settings.

Start with Stripe Test mode keys during development. Use test card number 4242 4242 4242 4242 to simulate payments. Switch to Live keys only when you are ready to accept real payments.

Send a welcome email when users sign up and notify them about usage milestones.

Connect Resend. Send these emails:
1. Welcome email when a new user signs up, with a brief intro to DraftAI and tips for getting started.
2. Upgrade confirmation email when a user subscribes to Pro, with a thank-you message and a summary of their new features.
3. Usage alert email when a free user hits 15 of their 20 daily messages, nudging them toward the Pro plan.
Use clean, minimal email templates that match the app's branding.

Push the app to production and run through the full user journey.

Use the Launch button in your Rocket project to deploy to the web. Rocket handles the Netlify build configuration automatically. Make sure all required environment variables are set in your project's integration settings before launching.

Test checklist:

  • Sign up with a new email and verify the welcome email arrives
  • Start a conversation and confirm GPT responses stream correctly
  • Create multiple conversations and switch between them
  • Send 20 messages to trigger the usage limit banner
  • Complete a Stripe test checkout and verify Pro features unlock
  • Cancel the subscription and confirm the user reverts to the free tier

Once testing is complete, switch to production credentials and launch.

  • Switch Stripe to live mode keys in the project environment variables
  • Confirm Supabase row-level security is enabled on all tables
  • Verify the OpenAI system prompt does not leak sensitive information
  • Redeploy with the production environment variables
  • Connect a custom domain if you have one

Customization ideas

Troubleshooting

On this page