https://github.com/barisgit/nextjs-nestjs-expo-template
Full Stack Typesafe Turborepo Boilerplate | Start quick with backend, web and mobile in NestJS, NextJS and Expo
https://github.com/barisgit/nextjs-nestjs-expo-template
expo nestjs nextjs template turborepo
Last synced: about 1 year ago
JSON representation
Full Stack Typesafe Turborepo Boilerplate | Start quick with backend, web and mobile in NestJS, NextJS and Expo
- Host: GitHub
- URL: https://github.com/barisgit/nextjs-nestjs-expo-template
- Owner: barisgit
- License: mit
- Created: 2025-04-02T00:31:12.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-25T17:31:41.000Z (about 1 year ago)
- Last Synced: 2025-04-25T18:38:50.260Z (about 1 year ago)
- Topics: expo, nestjs, nextjs, template, turborepo
- Language: TypeScript
- Homepage:
- Size: 5.77 MB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Next.js + NestJS + Expo Monorepo Template
[](https://opensource.org/licenses/MIT)
[](https://github.com/barisgit/nextjs-nestjs-expo-template/stargazers)
[](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)
## β¨ 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
Β Β
Β Β
Β Β
Β Β
Β Β
Β Β
Β Β
Β Β
Β Β
Β Β
Β Β
Β Β
Β Β
### 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
Loading...;
return (
Welcome, {data.name}!
);
}
```
### 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/)