Adding Features
This guide shows how to add new features following the conventions used throughout the codebase.Directory Conventions
| Layer | Location | Contains |
|---|---|---|
| Pages | app/(platform)/your-feature/ | Next.js App Router pages |
| API routes | app/api/your-feature/ | Route handlers |
| Server actions | lib/your-feature/actions.ts | "use server" functions |
| Types | lib/your-feature/types.ts | TypeScript types |
| Context/hooks | lib/your-feature/context.tsx | React context + hooks |
| UI components | components/your-feature/ | Feature-specific components |
| Migrations | supabase/migrations/ | Timestamped SQL files |
Migration Naming
Use a timestamp prefix that puts your migrations after the template’s own migrations:2026XXXX range. Use a date after the latest existing migration to ensure correct ordering.
Example: Adding a “Projects” Feature
Generate updated TypeScript types
types/database.types.ts from your Supabase schema.Caching Considerations
For workspace-scoped data protected by RLS, do not useunstable_cache(). It caches at the process level and bypasses RLS on cache hits, which can leak data across users.
Instead, use React cache() for request-scoped deduplication:
revalidateTag() with tag constants in lib/cache/tags.ts.
Pulling Template Updates
If the template receives upstream fixes, usesync-upstream.sh to pull changes into your fork while preserving your domain code: