A SaaS Kit offering end-to-end type safety with ts-rest between Next.js and Nest.js, along with integrated services like AuthJS for authentication, PostHog for analytics, and Drizzle ORM with PostgreSQL for database management.
Perfect to build scalable SaaS applications.
- End-to-end Type safety with ts-rest
- Dashboard and Landing Page with NextJS
- Optimistic UI with TanStack Query
- Database management with Drizzle ORM
- Authentication ready with NextAuth.js
- Containerized development environment
- Monorepo structure for efficient code organization
- Analytics with PostHog
- Ready-to-use ContentLayer for blog and changelog
- NextJS - Frontend framework
- NestJS - Backend framewor
- ts-rest - End-to-end type safety
- Drizzle ORM - Database management
- NextAuth.js - Authentication
- Docker - Containerization
- PostHog - Analytics
- Content Collections - Blog and changelog
This stack ensures a robust, scalable, and maintainable application with strong typing throughout the entire codebase and secure authentication.
- apps/web - The Next.js web application
- apps/server - The Nest.js API server
- packages/shared - The shared module which manages the database and ts-rest router for both the web and Server projects
To set up and run the project using Docker Compose:
-
Ensure you have Docker and Docker Compose installed on your system.
-
Open a terminal and navigate to the project's root directory.
-
Copy the example environment files and add appropriate environment variables:
cp apps/web/.env.example apps/web/.env.local cp .env.example .env cp apps/server/.env.example apps/server/.env cp packages/shared/.env.example packages/shared/.env
Edit
.env
files and add the necessary environment variables. Follow instructions in each file and modify the values according to your environment and the way you want to run the app. -
Remove all node_modules
rm -rf node_modules .pnpm-store ./apps/web/node_modules ./apps/server/node_modules ./packages/shared/node_modules ./apps/server/dist pg_data
-
Run the following command:
docker-compose -f docker-compose.dev.yml up
This command will build and start all the necessary containers defined in the docker-compose.dev.yml
file.
To set up and run the project locally using pnpm:
-
Make sure you have Node.js (version 18 or higher) and pnpm installed on your system.
-
Open a terminal and navigate to the project's root directory.
-
Copy the example environment files and add appropriate environment variables:
cp apps/web/.env.example apps/web/.env.local cp .env.example .env cp apps/server/.env.example apps/server/.env cp packages/shared/.env.example packages/shared/.env
Edit both
.env
files and add the necessary environment variables. Here docker-compose.postgres.yml used db credentials from .env file. So make sure the credentails that you used in apps.server/.env and packages.shared/.env are same as root .env file. Follow instructions in each file and modify the values according to your environment and the way you want to run the app. -
Install the dependencies by running:
pnpm install
-
Build the shared module
pnpm run build:shared
-
Start the PostgreSQL database using Docker Compose:
docker-compose -f docker-compose.postgres.yml up -d
-
Start the development servers by running:
pnpm run dev
This command will concurrently start both the Next.js web application (on port 8090) and the NestJS API server with shared module which manages db and ts-rest router. It uses Turbo to manage the monorepo workspace and run the development scripts for both the web and API projects simultaneously.
Make sure your environment variables are properly configured to connect to the PostgreSQL database started by Docker Compose.
Support me by giving a star ⭐ on this repository.
This project is licensed under the MIT License.