Next.js Application
This is the main web application of the monorepo, built with Next.js. The folder is named nextjs
to clearly indicate the framework being used, which helps with identifying the technology at a glance, especially in monorepos with multiple applications.
Check out our guide on Using Server Components with tRPC to learn how to properly use React Server Components with the tRPC setup in this project.
Application Structure
The Next.js application is organized as follows:
apps/nextjs/
├── public/ # Static assets
├── src/
│ ├── app/ # Next.js App Router structure
│ │ ├── _components/ # App-specific components
│ │ ├── api/ # API routes
│ │ │ ├── panel/ # tRPC UI panel
│ │ │ └── trpc/ # tRPC API endpoints
│ │ ├── layout.tsx # Root layout
│ │ └── page.tsx # Home page
│ ├── env.ts # Environment variable validation
│ ├── middleware.ts # Next.js middleware (for auth)
│ └── trpc/ # tRPC client configuration
Features
- Next.js 15 with App Router and Server Components
- React 19 for UI components
- Tailwind CSS for styling
- tRPC for end-to-end type-safe API
- Clerk for authentication
- Integration with shared packages from the monorepo
Key Files
src/app/layout.tsx
: The root layout that wraps all pagessrc/app/page.tsx
: The home page componentsrc/trpc/server.tsx
: tRPC server setup with procedure definitionssrc/env.ts
: Environment variable validation using zod
📄️ Local Development
Quickstart
📄️ Server Components with tRPC
Next.js 15 with the App Router makes heavy use of React Server Components (RSC), which can be powerful but require specific patterns when working with tRPC. This guide explains how to effectively use Server Components with the tRPC setup in this monorepo.
📄️ Vercel Deployment
Let's deploy the Next.js application to Vercel. If you've never deployed a Turborepo app there, don't worry, the steps are quite straightforward. You can also read the official Turborepo guide on deploying to Vercel.