Next.jsReact启动器

nextjs-nestjs-expo-template — Next.js 启动器模板

作者 barisgit

基于 Turborepo 的全栈 TypeScript 单体仓库模板,集成 NestJS 后端、Next.js Web 端与 Expo 移动端,并通过 tRPC 与类型化 WebSocket 实现端到端类型安全。

看看你的网站会是什么样

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

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

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

全部页面与视图 2

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

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

值得关注的模板亮点

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

01

Turborepo + pnpm 组织的 monorepo,包含 NestJS 后端、Next.js Web 端和 Expo 移动端三个应用

02

通过 tRPC 与类型化 Socket.IO 封装实现前后端端到端类型安全

03

packages/ 下提供 db、services、trpc、ui、websockets、analytics 等可复用共享包

04

数据层使用 TypeORM 与 PostgreSQL,认证接入 Clerk,分析接入 PostHog

05

Web 端使用 TailwindCSS 与 ShadCN UI,移动端使用 Tamagui

06

提供 pnpm dev:setup 一键初始化脚本,处理环境变量、数据库、Redis、迁移与种子数据

模板详细介绍

这是一个面向全栈 TypeScript 项目的 monorepo 启动模板,使用 Turborepo 与 pnpm 组织工作区。仓库把后端、Web 端和移动端拆分为 apps/backend(NestJS)、apps/web(Next.js)和 apps/mobile(Expo React Native)三个应用,并在 packages/ 下提供 analytics、db、services、trpc、ui、websockets 等共享包,用于复用数据库模型、认证与 Redis 服务、tRPC 路由、UI 组件和类型化 WebSocket 实现。

模板强调端到端类型安全:后端与前端之间通过 tRPC 传递类型,实时通信基于 Socket.IO 并封装为类型化客户端与事件。数据层使用 TypeORM 连接 PostgreSQL,认证接入 Clerk,产品分析接入 PostHog。Web 端使用 TailwindCSS 与 ShadCN UI,移动端使用 Tamagui。

使用前需要准备 Node.js(v18+)、PostgreSQL 和 pnpm;仓库提供 pnpm dev:setup 脚本,用于复制 .env 文件、通过 Docker 或手动方式配置数据库与 Redis、执行迁移和填充种子数据,随后可用 pnpm dev 同时启动三个开发服务,或分别运行 dev:backend、dev:web、dev:mobile。仓库还包含 scripts/ 目录下的环境变量检查脚本,以及各应用和包各自的 README 文档。

Next.js启动器

适合你的项目吗?

适用场景

  • 需要同时开发 Web 与移动端、并希望共享类型与业务逻辑的全栈项目
  • 以 NestJS 作为 API 服务、Next.js 作为 Web 前端、Expo 作为移动端的组合式开发
  • 需要端到端类型安全 API 与类型化实时通信(如房间、消息事件)的项目
  • 希望以 monorepo 方式统一管理数据库模型、认证、分析与 UI 组件的团队

适合人群

  • 熟悉 TypeScript、pnpm 与 Turborepo 工作流的开发者
  • 需要 NestJS + Next.js + Expo 三端一体起步结构的团队
  • 计划使用 PostgreSQL、Clerk 与 PostHog 作为基础设施的项目
  • 希望以共享包形式复用 tRPC、WebSocket 与 UI 代码的全栈项目

上手与定制指南

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

  1. 1

    需要 Node.js(v18+)、PostgreSQL 和 pnpm,pnpm 可通过 npm install -g pnpm 安装

  2. 2

    克隆仓库后执行 pnpm i 安装依赖,再运行 pnpm dev:setup 完成环境变量、数据库、Redis、迁移与种子数据初始化

  3. 3

    若使用默认 Docker 方式配置 PostgreSQL 和 Redis,需确保 Docker 正在运行;脚本会提示输入必要信息或读取已有 .env 文件

  4. 4

    使用 pnpm dev 启动全部开发服务,也可分别运行 pnpm dev:backend、pnpm dev:web、pnpm dev:mobile

  5. 5

    可通过 pnpm inspect:envs 检查 apps/ 与 packages/ 下的 .env 文件内容,核对环境变量配置

查看仓库使用说明

授权与来源资料

使用条件与限制

免费使用 · 保留许可声明

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

使用时需要遵守

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

额外费用与待核对事项

  • 认证功能依赖第三方服务 Clerk,需要注册 Clerk 账号并配置 API 密钥,可能涉及外部服务费用。
  • 分析功能依赖第三方服务 PostHog,需要注册账号并配置 API 密钥,可能涉及外部服务费用。
  • 默认初始化脚本依赖 Docker 运行 PostgreSQL 和 Redis,需本地安装并启动 Docker。
  • 运行前需自行准备 Node.js v18+、PostgreSQL 数据库和 pnpm 包管理器。
  • 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
  • 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
查看原文依据

Permission is hereby granted, free of charge

许可证原文

- **👤 Authentication**: Clerk integration for secure user management

README 原文

- **📊 Analytics**: PostHog integration for tracking user behavior

README 原文

# NOTE: Ensure Docker is running if you rely on the default Docker setup for PostgreSQL and Redis.

README 原文

- Node.js (v18+) - PostgreSQL - pnpm (`npm install -g pnpm`)

README 原文
https://github.com/barisgit/nextjs-nestjs-expo-template/blob/main/LICENSEhttps://github.com/barisgit/nextjs-nestjs-expo-template/blob/main/README.md

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

项目核对记录与介绍依据

模板资料

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

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

这个项目需要核对什么

记录的仓库更新时间
2025-04-25
截图检查日期
2026-10-03

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

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

查看具体选型方法 →

介绍的制作与核对状态

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

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

查看当时使用的来源资料

SHA-256: 1792f795cd061c7268b6a5ca1e2506ea2964b8d069fb2ce3932e06682b0f7455

2026-10-03T00:41:00.778Z

来源文件 / 仓库
# Next.js + NestJS + Expo Monorepo Template

<div align="center">

<a href="https://nestjs.com"><img src="https://img.shields.io/badge/nestjs-%23E0234E.svg?style=for-the-badge&logo=nestjs&logoColor=white" alt="NestJS" /></a>
<a href="https://nextjs.org"><img src="https://img.shields.io/badge/Next-black?style=for-the-badge&logo=next.js&logoColor=white" alt="Next.js" /></a>
<a href="https://expo.dev"><img src="https://img.shields.io/badge/expo-1C1E24?style=for-the-badge&logo=expo&logoColor=#D04A37" alt="Expo" /></a>
<a href="https://www.typescriptlang.org"><img src="https://img.shields.io/badge/typescript-%23007ACC.svg?style=for-the-badge&logo=typescript&logoColor=white" alt="TypeScript" /></a>
<a href="https://tailwindcss.com"><img src="https://img.shields.io/badge/tailwindcss-%2338B2AC.svg?style=for-the-badge&logo=tailwind-css&logoColor=white" alt="TailwindCSS" /></a>
<a href="https://socket.io"><img src="https://img.shields.io/badge/Socket.io-black?style=for-the-badge&logo=socket.io&badgeColor=010101" alt="Socket.io" /></a>
<a href="https://typeorm.io"><img src="https://img.shields.io/badge/TypeORM-E83524?style=for-the-badge&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiI+PHBhdGggZmlsbD0id2hpdGUiIGQ9Ik0xNiA4SDhjLS4yNjYgMC0uNTIuMTA1LS43MDcuMjkzQTEgMSAwIDAgMCA3IDl2MTRhMSAxIDAgMCAwIDEgMWg4YTEgMSAwIDAgMCAxLTFWOWExIDEgMCAwIDAtMS0xem0tMSAydjEySDl2LTEyem05LTJoLThhMSAxIDAgMCAwLTEgMXYxNGExIDEgMCAwIDAgMSAxaDhhMSAxIDAgMCAwIDEtMVY5YTEgMSAwIDAgMC0xLTF6bS0xIDJ2MTJoLTZ2LTEyeiIvPjwvc3ZnPg==" alt="TypeORM" /></a>
<a href="https://trpc.io"><img src="https://img.shields.io/badge/tRPC-%232596BE.svg?style=for-the-badge&logo=trpc&logoColor=white" alt="tRPC" /></a>
<a href="https://tamagui.dev"><img src="https://img.shields.io/badge/Tamagui-2C4159?style=for-the-badge&logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAyNCIgaGVpZ2h0PSIxMDI0IiB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8Y2lyY2xlIGN4PSI1MTIiIGN5PSI1MTIiIHI9IjUxMiIgZmlsbD0iIzE4QTBGQiIvPgo8cGF0aCBkPSJNMjY1Ljg1MSAyNDMuOTFWNDk3LjAwN0MyNjUuODUxIDU0MC42MjMgMzAxLjIzNSA1NzYuMDA3IDM0NC44NTEgNTc2LjAwN0g1OTUuNDc3QzYzOS4wOTMgNTc2LjAwNyA2NzQuNDc3IDU0MC42MjMgNjc0LjQ3NyA0OTcuMDA3VjI0My45MUw0NjguNjgxIDc5LjYzMzNDNDUxLjk5NSA2OC42ODE5IDQyOS45NDMgNjguNjM1OCA0MTMuMjE5IDc5LjUxNzJMMjY1Ljg1MSAyNDMuOTFaIiBmaWxsPSJ3aGl0ZSIvPgo8cGF0aCBkPSJNNzYxLjQ1NSA3NzguNzc1VjUyNS42NzlDNzYxLjQ1NSA0ODIuMDYzIDcyNi4wNzEgNDQ2LjY3OSA2ODIuNDU1IDQ0Ni42NzlINDMxLjgyOUMzODguMjEzIDQ0Ni42NzkgMzUyLjgyOSA0ODIuMDYzIDM1Mi44MjkgNTI1LjY3OVY3NzguNzc1TDU1OC42MjUgOTQzLjA1MkM1NzUuMzExIDk1NC4wMDMgNTk3LjM2MyA5NTQuMDUgNjE0LjA4NyA5NDMuMTY4TDc2MS40NTUgNzc4Ljc3NVoiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPg==" alt="Tamagui" /></a>
<a href="https://clerk.com"><img src="https://img.shields.io/badge/Clerk-6C47FF?style=for-the-badge&logo=clerk&logoColor=white" alt="Clerk" /></a>
<a href="https://tanstack.com/query"><img src="https://img.shields.io/badge/TanStack%20Query-FF4154?style=for-the-badge&logo=react-query&logoColor=white" alt="TanStack Query" /></a>
<a href="https://posthog.com"><img src="https://img.shields.io/badge/PostHog-000000?style=for-the-badge&logo=posthog&logoColor=white" alt="PostHog" /></a>
<a href="https://www.postgresql.org"><img src="https://img.shields.io/badge/postgres-%23316192.svg?style=for-the-badge&logo=postgresql&logoColor=white" alt="PostgreSQL" /></a>
<a href="https://turbo.build"><img src="https://img.shields.io/badge/Turborepo-000000?style=for-the-badge&logo=turborepo&logoColor=white" alt="Turborepo" /></a>

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Stargazers](https://img.shields.io/github/stars/barisgit/nextjs-nestjs-expo-template.svg?style=flat-square)](https://github.com/barisgit/nextjs-nestjs-expo-template/stargazers)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)

A modern full-stack, type-safe monorepo template with real-time capabilities and cross-platform support.

[Demo](https://demo-link.com) · [Report Bug](https://github.com/barisgit/nextjs-nestjs-expo-template/issues) · [Request Feature](https://github.com/barisgit/nextjs-nestjs-expo-template/issues)

</div>

<!-- <p align="center">
  <img src="https://via.placeholder.com/800x400?text=Next.js+NestJS+Expo+Template" alt="Project Banner" width="800"/>
</p> -->

## ✨ Features

- **📦 Monorepo Setup**: Turborepo with pnpm for efficient workspace management
- **🔄 Full Type Safety**: End-to-end type safety from backend to frontend with tRPC and typed WebSockets
- **🚀 Modern Stack**: Next.js, NestJS, and Expo with TypeScript
- **🔌 Real-time Communication**: Type-safe WebSockets integration with Socket.IO
- **👤 Authentication**: Clerk integration for secure user management
- **📊 Analytics**: PostHog integration for tracking user behavior
- **🎨 UI Components**: TailwindCSS with ShadCN UI for web and Tamagui for mobile
- **🧩 Modular Architecture**: Well-organized packages for code sharing

## 🚀 Quick Start

### Prerequisites

- Node.js (v18+)
- PostgreSQL
- pnpm (`npm install -g pnpm`)

### One-click Setup

```bash
# Clone the repository
git clone https://github.com/barisgit/nextjs-nestjs-expo-template.git
cd nextjs-nestjs-expo-template

# Install dependencies
pnpm i # or pnpm install

# Run the development setup script 
# This command handles:
#  - Copying .env files
#  - Setting up database (Docker or manual)
#  - Setting up Redis (Docker)
#  - Running database migrations
#  - Seeding the database
pnpm dev:setup

# NOTE: Ensure Docker is running if you rely on the default Docker setup for PostgreSQL and Redis.
# The script will prompt you for necessary details or use .env files if they exist.

# Start all development servers (Backend, Web, Mobile)
pnpm dev

# Or run individual servers:
# pnpm dev:backend # NestJS
# pnpm dev:web     # Next.js
# pnpm dev:mobile  # Expo
```

## 📂 Project Structure

```text
nextjs-nestjs-expo-template/
├── apps/
│   ├── backend/     # NestJS API server
│   ├── web/         # Next.js web application
│   └── mobile/      # Expo React Native application
├── packages/
│   ├── analytics/   # PostHog analytics integration
│   ├── db/          # Database models and TypeORM configuration
│   ├── services/    # Shared services (auth, redis, webhooks)
│   ├── trpc/        # tRPC API router definitions and context
│   ├── ui/          # Shared UI components (ShadCN UI for web)
│   ├── websockets/  # Type-safe WebSocket implementation
│   ├── eslint-config/ # Shared ESLint configuration
│   └── typescript-config/ # Shared TypeScript configuration
```

## 🖥️ Tech Stack

<p align="center">
  <a href="https://nestjs.com/"><img src="https://docs.nestjs.com/assets/logo-small.svg" alt="NestJS" width="50" /></a>&nbsp;&nbsp;
  <a href="https://nextjs.org/"><img src="https://cdn.worldvectorlogo.com/logos/next-js.svg" alt="Next.js" width="50" /></a>&nbsp;&nbsp;
  <a href="https://expo.dev/"><img src="https://www.vectorlogo.zone/logos/expoio/expoio-icon.svg" alt="Expo" width="50" /></a>&nbsp;&nbsp;
  <a href="https://trpc.io/"><img src="https://avatars.githubusercontent.com/u/78011399?s=200&v=4" alt="tRPC" width="50" /></a>&nbsp;&nbsp;
  <a href="https://www.typescriptlang.org/"><img src="https://cdn.worldvectorlogo.com/logos/typescript.svg" alt="TypeScript" width="50" /></a>&nbsp;&nbsp;
  <a href="https://tailwindcss.com/"><img src="https://cdn.worldvectorlogo.com/logos/tailwindcss.svg" alt="TailwindCSS" width="50" /></a>&nbsp;&nbsp;
  <a href="https://socket.io/"><img src="https://cdn.worldvectorlogo.com/logos/socket-io.svg" alt="Socket.io" width="50" /></a>&nbsp;&nbsp;
  <a href="https://typeorm.io/"><img src="https://raw.githubusercontent.com/typeorm/typeorm/master/resources/logo_big.png" alt="TypeORM" height="50" /></a>&nbsp;&nbsp;
  <a href="https://tamagui.dev/"><img src="https://avatars.githubusercontent.com/u/94025540?s=48&v=4" alt="Tamagui" height="50" /></a>&nbsp;&nbsp;
  <a href="https://ui.shadcn.com/"><img src="https://avatars.githubusercontent.com/u/139895814?s=200&v=4" alt="shadcn/ui" height="50" /></a>&nbsp;&nbsp;
  <a href="https://clerk.com/"><img src="https://clerk.com/images/clerk-logo.svg" alt="Clerk" height="50" /></a>&nbsp;&nbsp;
  <a href="https://tanstack.com/query"><img src="https://tanstack.com/_build/assets/logo-color-100w-br5_Ikqp.png" alt="TanStack Query" height="50" /></a>&nbsp;&nbsp;
  <a href="https://posthog.com/"><img src="https://posthog.com/brand/posthog-logo.svg" alt="PostHog" height="50" /></a>&nbsp;&nbsp;
  <a href="https://turbo.build/"><img src="https://turbo.build/images/docs/repo/repo-hero-logo-dark.svg" alt="Turborepo" height="50" /></a>
</p>

### Backend

- **NestJS**: A progressive Node.js framework for scalable server-side applications
- **TypeORM**: ORM for TypeScript and JavaScript with PostgreSQL
- **Socket.IO**: Real-time bidirectional event-based communication with type safety
- **PostgreSQL**: Open-source relational database

### Frontend

- **Next.js**: React framework for production-grade applications
- **TailwindCSS**: Utility-first CSS framework
- **ShadCN UI**: Beautifully designed components built with Radix UI and Tailwind CSS
- **TanStack Query**: Data fetching and caching library

### Mobile

- **Expo**: Platform for making universal React applications
- **React Native**: Framework for building native apps using React
- **Tamagui**: UI library for React Native with performance and developer experience in mind

### Common

- **TypeScript**: Typed superset of JavaScript
- **tRPC**: End-to-end typesafe APIs
- **Turborepo**: High-performance build system for JavaScript/TypeScript monorepos
- **Clerk**: Authentication and user management
- **PostHog**: Open-source product analytics platform

## 📖 Documentation

Each package and application contains its own detailed documentation:

- [Backend Documentation](apps/backend/README.md)
- [Mobile Documentation](apps/mobile/README.md)
- [Analytics Package](packages/analytics/README.md)
- [Database Package](packages/db/README.md)
- [Services Package](packages/services/README.md)
- [tRPC Package](packages/trpc/README.md)
- [UI Package](packages/ui/README.md)
- [WebSockets Package](packages/websockets/README.md)

## 💡 Usage Examples

### Type-safe API with tRPC

```tsx
// Client component
function UserProfile() {
  const { data, isLoading } = trpc.users.getProfile.useQuery();
  
  if (isLoading) return <div>Loading...</div>;
  
  return (
    <div>
      <h1>Welcome, {data.name}!</h1>
    </div>
  );
}
```

### Type-safe Real-time Communication

```tsx
// WebSocket setup with type safety
import { createTypedSocketClient, ClientEvents, ServerEvents } from '@repo/websockets';

const socket = createTypedSocketClient('http://your-api-url');
socket.emit(ClientEvents.JOIN_ROOM, roomId);

// Listen for messages with full type safety
socket.on(ServerEvents.MESSAGE, (message) => {
  console.log('New message:', message);
});
```

## 🛠️ Development Scripts

This project includes several helpful scripts for development and maintenance, located in the `scripts/` directory.

### Environment Variable Inspection

```bash
pnpm inspect:envs
```

This command scans the `apps/` and `packages/` directories for all `.env*` files (e.g., `.env`, `.env.local`, `.env.example`). It then prints the key-value pairs found in each file, grouped by project (app or package).

This is useful for:
- Verifying that all necessary environment variables are present in example files.
- Quickly checking the configured values across different environments.
- Debugging environment-related issues.

The script is powered by the `EnvManager` utility (`scripts/utilities/env-manager.ts`), which is designed to parse `.env` files while preserving comments and whitespace, making it useful for both reading and programmatically modifying environment configurations.

## 🤝 Contributing

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/amazing-feature`)
3. Commit your Changes (`git commit -m 'Add some amazing feature'`)
4. Push to the Branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## 📜 License

Distributed under the MIT License. See `LICENSE` for more information.

## 📧 Contact

Blaž Aristovnik - [@barisgit](https://github.com/barisgit) - [aristovnik.me](https://aristovnik.me)

## 🙏 Acknowledgments

- [Turborepo](https://turbo.build/)
- [NestJS](https://nestjs.com/)
- [Next.js](https://nextjs.org/)
- [Expo](https://expo.dev/)
- [tRPC](https://trpc.io/)
- [TypeORM](https://typeorm.io/)
- [Socket.IO](https://socket.io/)
- [ShadCN UI](https://ui.shadcn.com/)
- [Tamagui](https://tamagui.dev/)
- [Clerk](https://clerk.dev/)
- [PostHog](https://posthog.com/)
反馈内容错误

看看同类模板

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