FRMWRK
Next.js Boilerplate
Build tools with AI

Optional modules

Every module is scaffolded but disabled by default. Activate them via AI tools or manually.

Auth

Better Auth

disabled by default

Per-user login with sessions. Supports Magic Link (passwordless email), OTP, and TOTP (authenticator app).

Key files

  • lib/auth/
  • app/login/
  • proxy.ts

Environment variables

  • AUTH_SECRET
  • EMAIL_HOST
  • EMAIL_USER
  • EMAIL_PASS
  • EMAIL_FROM

How to activate

via AIrecommended

During setup: select this module in the /new-tool questionnaire — activated automatically.

After generation: run /add-feature and describe what you want to build — the AI activates the required modules.

manual

Remove [FEATURE: AUTH] comment wrappers in lib/auth/ and proxy.ts. Add AUTH_SECRET and email credentials to .env.

// lib/auth/index.ts (after activation)
import { betterAuth } from 'better-auth'
export const auth = betterAuth({
  emailAndPassword: { enabled: false },
  plugins: [magicLink({ sendMagicLink: sendEmail })],
})

// Check session in API routes:
const session = await auth.api.getSession({ headers: req.headers })
if (!session) return Response.json({ error: 'Unauthorized' }, { status: 401 })

Database

Prisma + SQLite

disabled by default

Relational database with type-safe ORM. SQLite by default (no server needed). Easy to swap to Postgres.

Key files

  • lib/db/
  • prisma/schema.prisma

Environment variables

  • DATABASE_URL

How to activate

via AIrecommended

During setup: select this module in the /new-tool questionnaire — activated automatically.

After generation: run /add-feature and describe what you want to build — the AI activates the required modules.

manual

Remove [FEATURE: DATABASE] wrappers in lib/db/. Define your models in prisma/schema.prisma, then run npm run db:push.

// prisma/schema.prisma
model User {
  id        String   @id @default(cuid())
  email     String   @unique
  name      String?
  createdAt DateTime @default(now())
}

// lib/db/index.ts
import { db } from '@/lib/db'
const users = await db.user.findMany()
const user  = await db.user.create({ data: { email, name } })

Background Jobs

node-cron

disabled by default

Scheduled background tasks running inside the Next.js process. No external services or credentials required.

Key files

  • lib/jobs/
  • instrumentation.ts

Environment variables

None — no credentials required

How to activate

via AIrecommended

During setup: select this module in the /new-tool questionnaire — activated automatically.

After generation: run /add-feature and describe what you want to build — the AI activates the required modules.

manual

Remove [FEATURE: JOBS] wrappers in lib/jobs/ and instrumentation.ts. Define your cron expressions and task logic.

// lib/jobs/cleanup.ts
import cron from 'node-cron'

export function startCleanupJob() {
  cron.schedule('0 2 * * *', async () => {
    // runs every day at 2 AM
    await db.session.deleteMany({
      where: { expiresAt: { lt: new Date() } },
    })
  })
}

Realtime

Express.js + SSE

disabled by default

Server-Sent Events for live updates. Replaces the Next.js dev server with a custom Express server.

Key files

  • server.ts

Environment variables

None — no credentials required

How to activate

via AIrecommended

During setup: select this module in the /new-tool questionnaire — activated automatically.

After generation: run /add-feature and describe what you want to build — the AI activates the required modules.

manual

Remove [FEATURE: SSE] wrappers in server.ts. Use npm run dev:sse instead of npm run dev. Push events via the /api/sse endpoint.

// Push an event from any API route:
import { sseEmitter } from '@/lib/sse'

sseEmitter.emit('update', { type: 'task_done', id: '123' })

// Subscribe on the client:
const es = new EventSource('/api/sse')
es.onmessage = (e) => {
  const data = JSON.parse(e.data)
  console.log('Live update:', data)
}

AI Integration

Vercel AI SDK

disabled by default

Streaming AI chat and completions. Supports Anthropic (Claude), OpenAI, and the local Claude CLI.

Key files

  • lib/ai.ts
  • app/api/chat/

Environment variables

  • AI_PROVIDER
  • ANTHROPIC_API_KEY
  • OPENAI_API_KEY

How to activate

via AIrecommended

During setup: select this module in the /new-tool questionnaire — activated automatically.

After generation: run /add-feature and describe what you want to build — the AI activates the required modules.

manual

Remove [FEATURE: AI] wrappers in lib/ai.ts. Set AI_PROVIDER in .env (anthropic, openai, or claude-cli) and add the corresponding API key.

// .env
AI_PROVIDER=anthropic
ANTHROPIC_API_KEY=sk-ant-...

// app/api/chat/route.ts (after activation)
import { streamText } from 'ai'
import { model } from '@/lib/ai'

export async function POST(req: Request) {
  const { messages } = await req.json()
  const result = streamText({ model, messages })
  return result.toDataStreamResponse()
}

Email

Nodemailer + SMTP

disabled by default

Transactional email sending via SMTP. Used by the Auth module for Magic Links, or standalone.

Key files

  • lib/email.ts

Environment variables

  • EMAIL_HOST
  • EMAIL_PORT
  • EMAIL_USER
  • EMAIL_PASS
  • EMAIL_FROM

How to activate

via AIrecommended

During setup: select this module in the /new-tool questionnaire — activated automatically.

After generation: run /add-feature and describe what you want to build — the AI activates the required modules.

manual

Remove [FEATURE: EMAIL] wrappers in lib/email.ts. Add your SMTP credentials to .env.

// lib/email.ts (after activation)
import { sendEmail } from '@/lib/email'

await sendEmail({
  to: 'user@example.com',
  subject: 'Your report is ready',
  html: '<p>Click <a href="...">here</a> to download.</p>',
})