AI Starter Kit
A starter kit for building AI applications using Next.js (opens in a new tab), Vercel AI SDK (opens in a new tab), Drizzle ORM (opens in a new tab), and PostgreSQL.
Getting Started
We are using npm as our package manager.
To use Yarn or any other package manager, delete the package-lock.json file and run the below commands using the package manager of your choice.
- Install dependencies
npm install- Rename
.env.exampleto.envand set the environment variables
.env
DATABASE_URL="postgresql://..."
OPENAI_API_KEY=
# Auth ------
AUTH_SECRET=
NEXTAUTH_URL=
AUTH_GOOGLE_ID=
AUTH_GOOGLE_SECRET=
AUTH_GITHUB_ID=
AUTH_GITHUB_SECRET=
NEXT_PUBLIC_DEMO_AUTH_EMAIL=
NEXT_PUBLIC_DEMO_AUTH_PASSWORD=
# SMTP -------
EMAIL_SERVER_HOST=
EMAIL_SERVER_PORT=
EMAIL_SERVER_USER=
EMAIL_SERVER_PASSWORD=
EMAIL_FROM=
# Stripe -----
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=
STRIPE_SECRET_KEY=
STRIPE_PRODUCT_ID=
STRIPE_WEBHOOK_SECRET=
NEXT_PUBLIC_PLUS_MONTHLY_PRICE_ID=
NEXT_PUBLIC_PLUS_YEARLY_PRICE_ID=
NEXT_PUBLIC_PRO_MONTHLY_PRICE_ID=
NEXT_PUBLIC_PRO_YEARLY_PRICE_ID=- Migrate the database
npm run db:generate # Generate the migrations
npm run db:migrate # Apply migrations to the databaseAlternatively, you can use the following command to directly apply changes to the database.
npm run db:push- Running locally
Install (opens in a new tab) and log in to your Stripe account:
stripe loginNow run the Next.js development server:
npm run devOpen http://localhost:3000 (opens in a new tab) in your browser to see the app in action.
You can listen for Stripe webhooks locally through their CLI to handle subscription change events:
stripe listen --forward-to localhost:3000/api/webhooks/stripeFeatures
- Next.js (opens in a new tab) App Router
- Advanced routing, SEO, and performance
- React Server Components (RSCs) and Server Actions for server-side rendering
- AI SDK (opens in a new tab)
- Unified API for generating text, structured objects, and tool calls with LLMs
- Supports OpenAI (default) and other model providers.
- Data Persistence
- PostgreSQL with Drizzle ORM (opens in a new tab) for saving chat history and user data
- Auth.js (opens in a new tab)
- Simple and secure authentication