sync.targets to specify the frontends to sync to.
Basic Structure
targets
Specifies the list of frontend projects to synchronize. Type:string[] (required)
How It Works
When Entities or APIs change, Sonamu automatically generates and synchronizes the following files to each target directory:-
Type Definitions (
{entity}.types.ts)- TypeScript types generated from Entity fields
- Zod validation schemas
- Subset types
-
Service Classes (
{entity}.service.ts)- Type-safe methods for API calls
- TanStack Query integration ready
Directory Structure
Single Frontend
The most common case, using only one web frontend.web/src/services/
Multiple Frontends
When developing web and app (React Native, Flutter, etc.) simultaneously:web/src/services/app/src/services/
target Directory Location
By default, Sonamu looks for directories with the same name as the target in the project root.Custom Paths
If target directories are in different locations, you can use relative paths:Verifying Sync
When you modify and save an Entity, sync messages appear in the console:Generated Files
Two files are generated for each Entity: user.types.ts:Disabling Sync
If thereβs no frontend or sync is not needed, specify an empty array:Sync can be disabled for API-only projects (e.g., microservices).
Practical Examples
Basic Web Project
Web + Mobile App
Monorepo Structure
Sync Cautions
1. Donβt Modify Auto-generated Files
Synced files are auto-generated, so donβt modify them directly.2. Git Management
Commit synced files to Git.- Team members can develop frontend without running backend
- CI/CD can build frontend without Sonamu
3. Verify target Directory Exists
The directory specified as target must exist.Frontend Setup
Some configuration is needed in the frontend to use synced Services.1. API Client Setup
web/src/lib/api-client.ts:2. Using Services
Next Steps
After completing sync target configuration:- frontend-integration - How to use Services
- storage - File storage settings
- cache - Cache settings