npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

create-saas-app-ai-chat

v1.0.4

Published

Create a production-ready AI SaaS with Next.js, Supabase, Stripe, and OpenRouter - 15+ AI models included

Readme

create-saas-app-ai-chat

npm version License: MIT Node.js

Create a production-ready AI SaaS application with Next.js 15, Supabase, Stripe, and OpenRouter in seconds. Perfect for indie hackers, startups, and developers who want to launch fast.

✨ Features

🤖 AI Chat Platform

  • 15+ AI Models - Access Claude, GPT-4, Gemini, Llama, DeepSeek, and more through OpenRouter
  • Multi-Model Support - Switch between models seamlessly
  • Context Management - Automatic conversation summarization for long chats
  • Code Artifact Detection - Beautiful rendering of code blocks and artifacts
  • Credit-Based Billing - Precise USD-based usage tracking (6 decimal precision)

🔐 Authentication

  • Supabase Auth - Production-ready authentication
  • PKCE Flow - Enhanced security for OAuth
  • Multiple Providers - Email/password + OAuth (Google, GitHub, etc.)
  • Session Management - Server-side sessions with automatic refresh
  • Protected Routes - Middleware-based route protection

💳 Payments & Subscriptions

  • Stripe Integration - Complete subscription system
  • Trial System - 7-day monthly / 14-day yearly trials with $1 credit
  • Customer Portal - Self-service subscription management
  • Webhook Handling - Automated event processing
  • Credit Allocation - Automatic monthly credit resets

🎨 UI/UX

  • shadcn/ui - Beautiful, accessible components
  • MagicUI - Animated components for modern feel
  • Tailwind CSS 4 - Latest styling framework
  • Dark Mode - Built-in theme switching
  • Responsive Design - Mobile-first approach
  • Framer Motion - Smooth animations

🗄️ Database & Backend

  • PostgreSQL - Hosted on Neon via Supabase
  • Drizzle ORM - Type-safe database queries
  • Server Actions - Type-safe mutations
  • API Routes - RESTful endpoints
  • Activity Logging - Complete audit trail
  • Usage Analytics - Track token consumption and costs

🚀 Developer Experience

  • TypeScript - Full type safety
  • Next.js 15 - Latest features (App Router, Server Components)
  • Turbopack - Lightning-fast dev server
  • Setup Wizard - Interactive configuration in dev mode
  • Hot Reload - Instant updates during development

🎯 Why Choose This Template?

| Feature | create-saas-app-ai-chat | Other Templates | |---------|------------------------|-----------------| | AI Integration | ✅ 15+ models via OpenRouter | ❌ Usually none | | Stripe Setup | ✅ Complete with trials & webhooks | ⚠️ Basic or missing | | Auth System | ✅ Production-ready with OAuth | ⚠️ Often incomplete | | Type Safety | ✅ End-to-end TypeScript + Drizzle | ⚠️ Partial | | Documentation | ✅ Comprehensive guides | ⚠️ Basic | | Setup Wizard | ✅ Interactive dev setup | ❌ Manual config |

🚀 Quick Start

npx create-saas-app-ai-chat my-awesome-saas
cd my-awesome-saas

The CLI will guide you through:

  1. Setting your app name and branding
  2. Configuring support email
  3. Adding social media links (optional)

📦 What's Included

Frontend

  • Next.js 15 - App Router, React Server Components
  • React 19 - Latest React features
  • TypeScript 5 - Strict mode enabled
  • Tailwind CSS 4 - Modern styling
  • shadcn/ui - Radix UI primitives
  • MagicUI - Animated components
  • Framer Motion - Animations
  • Recharts - Usage analytics charts
  • next-themes - Dark mode support

Backend & Database

  • Next.js API Routes - Serverless functions
  • Next.js Server Actions - Type-safe mutations
  • PostgreSQL - Neon via Supabase
  • Drizzle ORM 0.43.1 - Type-safe queries
  • Drizzle Kit - Database migrations

Authentication

  • Supabase Auth - Latest version
  • @supabase/ssr - SSR-safe sessions
  • OAuth Support - Google, GitHub, etc.
  • PKCE Flow - Enhanced security

Payments

  • Stripe 19.1.0 - Subscriptions, checkout, webhooks
  • Customer Portal - Self-service management
  • Trial System - 7-day monthly, 14-day yearly
  • Credit System - USD-based billing

AI Integration

  • OpenRouter API - Multi-model gateway
  • OpenAI SDK 6.3.0 - Client library
  • gpt-tokenizer - Token estimation
  • tiktoken - Token counting
  • 15+ Models - Claude, Gemini, Llama, DeepSeek, etc.

Email

  • Resend 6.1.2 - Transactional emails

🛠️ Setup

After creating your project:

1. Install Dependencies

pnpm install
# or
npm install

2. Configure Environment Variables

cp .env.example .env.local

Edit .env.local and add your credentials:

  • Supabase: URL, anon key, service role key, database URL
  • Stripe: Secret key, publishable key, webhook secret
  • OpenRouter: API key
  • Resend: API key and email addresses

3. Set Up Database

pnpm db:push

This creates all necessary tables in your Supabase database.

4. Configure Stripe

  1. Create products in Stripe Dashboard
  2. Add metadata: {"ai_credits_amount": "50.00"}
  3. Set up webhook: https://yourdomain.com/api/stripe/webhook
  4. Add webhook events: checkout.session.completed, customer.subscription.updated, customer.subscription.deleted

5. Start Development Server

pnpm dev

Visit http://localhost:3000/setup for the interactive setup wizard (dev only).

6. Access Your App

  • Homepage: http://localhost:3000
  • Dashboard: http://localhost:3000/dashboard (after signup)
  • Setup Wizard: http://localhost:3000/setup (dev only)

📚 Documentation

The generated project includes comprehensive documentation:

  • README.md - Complete setup and deployment guide
  • CLAUDE.md - Detailed codebase documentation
  • Database Schema - All tables and relationships explained
  • API Routes - Endpoint documentation
  • Server Actions - Available actions and usage

🏗️ Project Structure

my-saas/
├── app/                    # Next.js App Router
│   ├── (marketing)/        # Public pages
│   ├── (protected)/        # Authenticated routes
│   ├── api/               # API endpoints
│   └── auth/              # Auth pages
├── components/            # React components
│   ├── ui/               # shadcn/ui components
│   └── magicui/          # Animated components
├── lib/                   # Business logic
│   ├── db/               # Database & schema
│   ├── supabase/         # Supabase clients
│   ├── payments/         # Stripe integration
│   ├── ai/               # OpenRouter integration
│   └── actions/          # Server actions
├── hooks/                 # React hooks
├── types/                 # TypeScript types
├── prompts/              # AI system prompts
└── public/               # Static assets

🚢 Deployment

Vercel (Recommended)

  1. Push to GitHub
  2. Import to Vercel
  3. Configure environment variables
  4. Deploy

Other Platforms

  • Works on any Node.js 18+ hosting
  • Update Stripe webhook URL after deployment
  • Update Supabase redirect URLs

🧪 Tech Stack

| Category | Technology | |----------|-----------| | Framework | Next.js 15, React 19 | | Language | TypeScript 5 | | Styling | Tailwind CSS 4, shadcn/ui | | Database | PostgreSQL (Neon) | | ORM | Drizzle ORM | | Auth | Supabase Auth | | Payments | Stripe | | AI | OpenRouter | | Email | Resend | | Deployment | Vercel |

🐛 Troubleshooting

Common Issues

Setup wizard not loading?

  • Ensure NODE_ENV=development
  • Check SETUP_COMPLETE is not set to true in .env.local
  • Try accessing /setup?force=true

Stripe webhooks failing?

  • Verify webhook secret matches
  • Test with Stripe CLI: stripe listen --forward-to localhost:3000/api/stripe/webhook
  • Check webhook events are enabled

Database connection errors?

  • Verify DATABASE_URL is correct
  • Check Supabase project is active
  • Test connection in setup wizard

AI chat not working?

  • Verify OPENROUTER_API_KEY is set
  • Check user has active subscription and credits
  • Inspect browser console for errors

Credits not deducting?

  • Check webhook events are firing
  • Verify token_usage_logs table has entries
  • Review aiCreditsBalance in user_profiles

🔗 Resources

Documentation Links

🤝 Contributing

Contributions are welcome! Please open an issue or submit a pull request.

📝 License

MIT License - see LICENSE file for details.

👨‍💻 Author

A1X6


Made with ❤️ for indie hackers and SaaS builders

Start building your AI SaaS today:

npx create-saas-app-ai-chat my-saas