AiStarterKit
A starter kit for building AI applications using Next.js , Vercel AI SDK , Drizzle ORM , 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.example
to.env
and set the environment variables.envDATABASE_URL="postgresql://..." OPENAI_API_KEY= # Auth ------ AUTH_SECRET= 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 database
Alternatively, you can use the following command to directly apply changes to the database.
npm run db:push
-
Running Locally Install and log in to your Stripe account:
stripe login
Now run the Next.js development server:
npm run dev
Open http://localhost:3000 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/stripe
Features
-
Next.js App Router
- Advanced routing, SEO, and performance
- React Server Components (RSCs) and Server Actions for server-side rendering
-
- 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 for saving chat history and user data
-
- Simple and secure authentication