Back to templates

Template details

Next.js Billing App with Lemon Squeezy

A Next.js 14 starter template with Lemon Squeezy billing, GitHub OAuth, Drizzle ORM, and Neon Postgres.

About this template

The Next.js Billing App with Lemon Squeezy is a Boilerplate template that provides a ready-made auth and billing foundation for subscription SaaS products, built on Next.js 14 with TypeScript, Drizzle ORM, and Tailwind CSS.

What is the Next.js Billing App with Lemon Squeezy?

The template is a demo application that combines Lemon Squeezy subscription billing, GitHub OAuth authentication, and a Drizzle-managed Neon Postgres database in a single Next.js 14 codebase. It takes environment variables for API keys, store IDs, and database URLs as input, and produces a working SaaS starter with a customer portal alternative, webhook handling, and login flow. The app is built on the Next.js App Router, which supports enhanced layouts, component colocation, and component-level data fetching.

Key Features

  • Next.js 14 App Router — Uses the App Router for file-based routing, layouts, and server components, with support for Vercel Edge Functions and serverless deployments.
  • Lemon Squeezy billing integration — Includes a ready-made billing layer with webhook processing for subscription_created and subscription_updated events, plus a server action that demonstrates creating webhooks via the Lemon Squeezy SDK.
  • Auth.js v5 with GitHub OAuth — Authentication is handled by Auth.js v5, configured through environment variables for GitHub OAuth client ID and secret.
  • Drizzle ORM and Neon serverless Postgres — Database schema is managed with Drizzle ORM and pushed to Neon, giving you access to Drizzle Studio for inspecting records at local.drizzle.studio.
  • Wedges component library — Styling uses Tailwind CSS with Lemon Squeezy's Wedges components, providing a pre-built UI foundation.
  • Environment-based configuration — All third-party credentials (Lemon Squeezy API key, store ID, webhook secret, Postgres URL, GitHub OAuth) are set in a .env file with a documented example.
  • Production migration guidance — The README explains how to switch from Test mode to live mode, including updating the API key and creating a webhook for the live store.

Who is it for?

  • SaaS founders — Bootstrap a subscription app with billing already wired up, avoiding the need to build payment integration from scratch.
  • Next.js developers — Start from a TypeScript, App Router codebase with pre-configured auth, database, and billing layers to customize.
  • Lemon Squeezy users — Evaluate how integrated billing compares to the built-in Customer Portal, and use the template as a working reference implementation.
  • Indie hackers — Quickly launch a paid SaaS product on a serverless stack with GitHub login and subscription management.

What can you do with this template?

  • Set up subscription billing: Connect a Lemon Squeezy store and automatically handle subscription creation and update webhooks to track user entitlements.
  • Add GitHub login: Enable GitHub OAuth authentication so users can sign in to your app with their GitHub accounts.
  • Manage data with Drizzle Studio: Run pnpm db:studio to open Drizzle Studio and inspect or edit subscription records in your Neon Postgres database.
  • Extend the billing system: Add handlers for additional Lemon Squeezy events such as subscription_payment_success to list invoices or send receipts.

How does this template work?

Clone the repository, install dependencies with pnpm install, and copy .env.example to .env. Fill in the environment variables for Lemon Squeezy, Neon Postgres, GitHub OAuth, and auth secrets. Run pnpm db:push to set up the Drizzle schema, then start the development server with pnpm dev. For webhooks, set up a webhook in Lemon Squeezy pointing to /api/webhook, or use the included setup webhook button.

FAQ

Does this template work on Vercel Edge Functions?

Yes. The template pairs Drizzle ORM with Neon serverless Postgres, which keeps the app compatible with Vercel Edge Functions and serverless deployments.

What webhook events does the demo process?

The demo processes subscription_created and subscription_updated. You can extend it to handle other events like subscription_payment_success to support invoices and payment history.

How do I receive webhooks during local development?

While running on localhost, your app cannot receive webhooks from Lemon Squeezy. Use a tunnel service such as ngrok or LocalCan to create a web-accessible URL and set it as the WEBHOOK_URL environment variable.

Do I need a Lemon Squeezy account and store?

Yes. You must create a Lemon Squeezy account and store, and use Test mode during development. The README explains how to generate an API key and store ID, and how to set up a webhook signing secret.

screenshot of Next.js Billing App with Lemon Squeezy on template0.com