Next.jsReactSaaS启动器

litesaas — Next.js SaaS模板

作者 locionic

LiteSaaS 是一个基于 Next.js 15 与 SQLite 的 SaaS 启动模板,使用 Drizzle ORM、自托管会话认证和 Litestream S3 备份,采用 MIT 许可。

看看你的网站会是什么样

浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。

2 个预览视图
桌面端首页1 / 2
桌面端截图首屏预览

由服务器浏览器实际访问页面后截取。

全部页面与视图 2

截图用于了解视觉与布局,交互效果请以实际项目为准。

采集于 2026-10-01查看来源

值得关注的模板亮点

从已有项目资料中,快速了解它的特点。

01

Next.js 15 App Router 与 Server Components 构建的 SaaS 启动模板

02

SQLite + Drizzle ORM,提供类型安全查询与 db:push 迁移脚本

03

预设 WAL、page_size、synchronous、busy_timeout、foreign_keys 等生产 PRAGMA

04

自托管会话认证,使用 crypto.scrypt 哈希密码与 HttpOnly Cookie

05

集成 Litestream,将 WAL 帧持续复制到 Cloudflare R2 或 AWS S3

06

包含 Stripe 与 LemonSqueezy 的结账会话与 webhook 处理代码

模板详细介绍

LiteSaaS 是一个面向独立开发者的 SaaS 启动模板,核心思路是用嵌入式 SQLite 替代托管 PostgreSQL,用自托管会话 Cookie 替代第三方认证服务,从而减少数据库与认证方面的外部依赖。模板基于 Next.js 15 的 App Router 与 Server Components 构建,数据层使用 Drizzle ORM,并提供 db:push 脚本用于同步 schema。认证部分使用 Node.js crypto.scrypt 做密码哈希,配合 HttpOnly Cookie 保存会话。数据库以 WAL 模式运行,并预设了 page_size、synchronous、busy_timeout、foreign_keys 等 PRAGMA 参数。备份方面集成 Litestream,可将 WAL 帧持续复制到 Cloudflare R2 或 AWS S3,容器启动时若检测到已有备份会先恢复数据库。模板还包含 Stripe 与 LemonSqueezy 的结账会话创建和 webhook 处理代码,以及基于 Tailwind CSS 的深色界面。

使用限制方面:SQLite 采用单写者模型,写入并发受限于一个活跃写入者,busy_timeout 仅用于重试而非提升写入吞吐;因此该模板更适合读多写少或中小规模写入的场景。Litestream 备份依赖外部对象存储,需要自行准备 R2 或 S3 凭据。演示站点提供的登录凭据仅用于体验,不应在生产环境沿用。README 中列出的性能对比数据来自作者自述的基准测试,未在模板资料中提供可复现的测试方法,使用前应结合自身负载验证。

Next.jsSaaS启动器

适合你的项目吗?

适用场景

  • 希望减少托管数据库与第三方认证服务依赖的 SaaS 项目
  • 部署在单台 VPS 或 Docker Compose 环境中的小型 Web 应用
  • 需要将 SQLite 数据库持续备份到 S3 兼容对象存储的场景
  • 需要快速搭建带登录、订阅结账与深色界面的 MVP

适合人群

  • 熟悉 Next.js 与 TypeScript 的独立开发者
  • 接受 SQLite 单写者模型、写入并发不高的项目
  • 愿意自行维护 VPS、Docker 与对象存储备份的团队
  • 需要 MIT 许可、可自由修改与商用的启动模板的使用者

上手与定制指南

结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。

  1. 1

    克隆仓库后执行 npm install,并复制 .env.example 为 .env 填写配置

  2. 2

    运行 npm run db:push 初始化 SQLite 数据库,再执行 npm run dev 启动开发服务器

  3. 3

    生产部署可使用 docker compose up -d,或自行配置 Node 运行环境

  4. 4

    启用 Litestream 备份需在 .env 中设置 LITESTREAM_BUCKET、LITESTREAM_ENDPOINT、LITESTREAM_ACCESS_KEY_ID 与 LITESTREAM_SECRET_ACCESS_KEY

  5. 5

    演示凭据 [email protected] / password123 仅用于体验,部署前应更换或移除

查看仓库使用说明

授权与来源资料

使用条件与限制

免费使用 · 保留许可声明

本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。

使用时需要遵守

  • 允许免费使用、修改、商用和分发该版本代码。
  • 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
  • 代码按现状提供;担保与责任限制以原许可证及适用法律为准。

额外费用与待核对事项

  • 认证采用自托管会话 Cookie 与 crypto.scrypt 哈希,不依赖 Clerk/Auth0 等第三方认证服务,无需为其付费。
  • 启用 Litestream 备份需自行提供 Cloudflare R2 或 AWS S3 凭据(bucket、endpoint、access key、secret key),属于外部服务依赖。
  • Stripe 与 LemonSqueezy 结账及 webhook 需自行注册对应支付服务账号并配置密钥,可能产生第三方费用。
  • 演示站点凭据仅用于体验,生产部署前应更换或移除,不应沿用。
  • SQLite 为单写者模型,写入并发受限于一个活跃写入者,busy_timeout 仅自动重试而非提升写入吞吐,适合读多写少场景。
  • 性能对比数据来自作者自述基准测试,未提供可复现方法,使用前应结合自身负载验证。
  • 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
  • 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
查看原文依据

Permission is hereby granted, free of charge

许可证原文

Self-Hosted Session Cookies (crypto.scrypt) - **$0/mo**

README 原文

LITESTREAM_BUCKET=my-app-db-backup

README 原文

Stripe & LemonSqueezy Ready

README 原文

Instant login: `[email protected]` / `password123`

README 原文

1 Active Writer (busy_timeout = 5000ms auto-retries)

README 原文

Benchmarked on a $5/mo AWS Lightsail instance (2 vCPU, 2GB RAM):

README 原文
https://github.com/locionic/litesaas/blob/main/LICENSEhttps://github.com/locionic/litesaas/blob/main/README.md

DeepSeek 根据仓库许可证和 README 整理 ·2026-10-01。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。

项目核对记录与介绍依据

模板资料

来源平台
GitHub
资料与维护参考分
资料较完整 · 85 / 100
技术栈
Next.js · React
网站类型
SaaS · 启动器
这个分数如何计算

本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。

这个项目需要核对什么

记录的仓库更新时间
2026-09-24
截图检查日期
2026-10-01

已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。

目录记录的主要技术栈是 Next.js。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。

查看具体选型方法 →

介绍的制作与核对状态

介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。

已完成服务器许可规则与 AI 来源核对;未经过人工编辑审核。

查看当时使用的来源资料

SHA-256: a73a09e14bbd7820fdae339a1318b6d5b17f82c0884bb84eaf4ada4a101769c5

2026-10-01T00:41:27.345Z

来源文件 / 仓库
# 🚀 LiteSaaS

> **The 100% Free, Zero-Cost Production Next.js 15 + SQLite SaaS Starter Kit.**  
> *Stop burning $25/mo on managed PostgreSQL instances for your side projects. Ship production apps with microsecond latencies and $0 database bills.*

[![Next.js 15](https://img.shields.io/badge/Next.js-15.1-black?style=flat&logo=next.js)](https://nextjs.org)
[![Live Demo](https://img.shields.io/badge/Live_Demo-Online-10b981?style=flat&logo=railway)](https://litesaas-production.up.railway.app)
[![SQLite WAL](https://img.shields.io/badge/SQLite-WAL_Mode-003B57?style=flat&logo=sqlite)](https://locionic.com/en/blog/sqlite-wal-mode-production-concurrency)
[![Drizzle ORM](https://img.shields.io/badge/Drizzle_ORM-0.38-C5F74F?style=flat)](https://orm.drizzle.team)
[![Tailwind CSS](https://img.shields.io/badge/Tailwind-3.4-38B2AC?style=flat&logo=tailwind-css)](https://tailwindcss.com)
[![License: MIT](https://img.shields.io/badge/License-MIT-emerald.svg)](LICENSE)

👉 **Live Interactive Demo:** [https://litesaas-production.up.railway.app](https://litesaas-production.up.railway.app) *(Instant login: `[email protected]` / `password123`)*

---

## ⚡ The Problem: "SaaS Bill Creep"

Every indie hacker knows the story: You build 3 or 4 side project MVPs. Even before getting your first paying customer, you are bleeding **$840+/year** on idle database hosting:

| Service | Traditional SaaS Boilerplate | LiteSaaS |
| :--- | :--- | :--- |
| **Database** | Managed PostgreSQL (Supabase/Neon) - **$25/mo** | Embedded SQLite with WAL Mode - **$0/mo** |
| **Authentication** | Clerk / Auth0 - **$25/mo** | Self-Hosted Session Cookies (crypto.scrypt) - **$0/mo** |
| **Database Backups** | Paid add-on snapshot storage | Litestream S3 / Cloudflare R2 Streaming - **$0/mo** |
| **Compute** | Serverless cold starts & overages | $4/mo VPS (Hetzner / Lightsail / Coolify) |
| **Annual Cost (3 MVPs)** | **$2,520 / year** | **$48 / year** |

LiteSaaS gives you the **exact same developer experience and safety** as a heavy Postgres setup, but runs on a single $4 VPS with zero database bills.

---

## 🏗️ Architecture: Why SQLite in Production Works

Most developers believe SQLite cannot handle production web traffic. That reputation comes from SQLite's **year-2000 legacy defaults**, not the engine itself. 

When tuned with production PRAGMAs, SQLite delivers **5,000+ req/sec concurrency** with **microsecond in-memory reads**:

```
[ Client Request ]
       │
       ▼
[ Next.js 15 App Router / Server Actions ]
       │
       ▼
[ SQLite Engine in WAL Mode ] ── (0.02ms in-memory C read, zero network lag)
       │
       ├─► 50 Concurrent Readers (Non-blocking)
       ├─► 1 Active Writer (busy_timeout = 5000ms auto-retries)
       │
       ▼
[ Litestream Daemon ] ────────── (Asynchronous physical WAL streaming)
       │
       ▼
[ Cloudflare R2 / AWS S3 ] ───── (Disaster recovery with < 1s RPO)
```

Read our complete research paper on SQLite concurrency mechanics:  
👉 **[Running SQLite in Production with WAL Mode & 1-Writer Pools (Locionic)](https://locionic.com/en/blog/sqlite-wal-mode-production-concurrency)**

---

## 📦 What's Inside

- **Next.js 15 (App Router & React 19)**: Built with modern Server Components and Server Actions.
- **SQLite + Drizzle ORM**: Fully type-safe relational queries with automatic schema migrations (`npm run db:push`).
- **Production PRAGMAs Pre-Wired**:
  - `PRAGMA page_size = 4096;` (aligned with NVMe block clusters)
  - `PRAGMA journal_mode = WAL;` (readers never block writers, writers never block readers)
  - `PRAGMA synchronous = NORMAL;` (crash-safe ACID without filesystem fsync stall)
  - `PRAGMA busy_timeout = 5000;` (eliminates `SQLITE_BUSY` errors during write bursts)
  - `PRAGMA foreign_keys = ON;` (enforces relational integrity)
- **Self-Hosted Session Auth**: Secure password hashing with Node.js `crypto.scrypt` and HttpOnly cookies. Zero third-party fees.
- **Stripe & LemonSqueezy Ready**: Checkout session creation and webhook handling pre-configured.
- **Streaming S3 Disaster Recovery**: Bundled with [Litestream](https://litestream.io) to continuously replicate WAL frames to Cloudflare R2 or S3.
- **Modern Linear-Style Dark Mode**: Crafted with Tailwind CSS and Radix-inspired aesthetics.

---

## 🚀 Quick Start (Under 60 Seconds)

### 1. Clone & Install

```bash
git clone https://github.com/locionic/litesaas.git
cd litesaas
npm install
```

### 2. Configure Environment

```bash
cp .env.example .env
```

### 3. Initialize Database & Run

```bash
npm run db:push
npm run dev
```

Open [http://localhost:3000](http://localhost:3000) in your browser. 

> **Instant Demo Credentials:**  
> Email: `[email protected]`  
> Password: `password123`

---

## 🐳 Production Deployment

### Option A: Docker Compose (Coolify / Dokku / VPS)

```bash
docker compose up -d
```

### Option B: Deploying with Litestream S3 Backup

Set your Cloudflare R2 or AWS S3 credentials in `.env`:

```env
LITESTREAM_BUCKET=my-app-db-backup
LITESTREAM_ENDPOINT=https://<account_id>.r2.cloudflarestorage.com
LITESTREAM_ACCESS_KEY_ID=xxx
LITESTREAM_SECRET_ACCESS_KEY=yyy
```

When the Docker container starts, Litestream automatically checks S3:
1. If an existing backup exists, it **restores your database in 2 seconds**.
2. As Next.js writes new transactions, Litestream **streams WAL frames continuously** to your bucket.

---

## 📊 Benchmark: SQLite vs Network PostgreSQL

Benchmarked on a $5/mo AWS Lightsail instance (2 vCPU, 2GB RAM):

| Metric | Managed PostgreSQL (over network) | LiteSaaS (Embedded SQLite) |
| :--- | :--- | :--- |
| **Single Row Read Latency** | 12ms – 24ms (network roundtrip) | **0.02ms – 0.05ms** (500x faster) |
| **Complex Relational Join** | 25ms – 45ms | **0.15ms** |
| **Max Concurrent Readers** | Pool limited (usually 20–50) | **Unlimited** (WAL concurrent readers) |
| **Memory Footprint** | ~350MB – 600MB daemon RAM | **~15MB RAM** |
| **Maintenance Burden** | Connection pools, SSL certs, users | **Zero ops (single file on disk)** |

---

## 🛠️ Tech Stack & Credits

- Framework: [Next.js](https://nextjs.org) by Vercel
- ORM: [Drizzle ORM](https://orm.drizzle.team)
- Database: [SQLite](https://www.sqlite.org) / [better-sqlite3](https://github.com/WiseLibs/better-sqlite3)
- Replication: [Litestream](https://litestream.io) by Ben Johnson
- Styling: [Tailwind CSS](https://tailwindcss.com) & [Lucide Icons](https://lucide.dev)

---

## 👨‍💻 Author & Attribution

Developed and maintained by **[Loc Truong](https://locionic.com)** ([@locionic](https://github.com/locionic)).

For interactive SQLite tuning, check out our companion tool:  
👉 **[SQLite Production PRAGMA Configurator](https://locionic.com/en/tools/sqlite-configurator)**

---

## 📄 License

MIT License — Feel free to use this template for personal, open-source, or commercial SaaS projects!
反馈内容错误

看看同类模板

对比同技术栈与用途的模板,找到更适合的视觉与内容结构。