Why Monorepos for Modern Web Apps?
As web applications grow in complexity, keeping your frontend, API backend, and data validation schemas synchronized becomes a major architectural challenge. A monorepo structure allows teams to share TypeScript types, Zod schemas, and utility functions effortlessly.
1. Workspace Setup with Pnpm
Pnpm workspaces offer unmatched speed and disk space efficiency compared to traditional package managers. Our repository is structured as follows:
apps/frontend: Nuxt 3 application with SSR and i18n support.apps/backend: Hono API server powered by Drizzle ORM.packages/shared: Centralized Zod schemas, API interfaces, and domain types.
2. Sharing Zod Schemas across Layers
By importing validation schemas directly from @repo/shared, both frontend forms and backend request validation handlers stay strictly typed without code duplication.
import { z } from 'zod'
export const UserSchema = z.object({
id: z.string().uuid(),
name: z.string().min(2),
email: z.string().email(),
role: z.enum(['admin', 'user'])
})
export type User = z.infer<typeof UserSchema>
Conclusion
Adopting a pnpm workspace monorepo dramatically improves developer experience and eliminates type mismatch bugs in production.

