Directory Overview
Root Files
The root of your project contains configuration files that tie everything together.package.json
package.json
Defines your monorepo workspace structure using Bun workspaces. It includes scripts to run your app and backend together.Run
bun run dev to start both the frontend and backend simultaneously.turbo.json
turbo.json
Configures Turborepo, which orchestrates tasks across your monorepo. It defines how
dev, build, lint, and typecheck commands run across packages..env
.env
Stores environment variables shared across your app. Required variables:
CONVEX_DEPLOYMENT— Your Convex deployment identifierEXPO_PUBLIC_CONVEX_URL— The Convex cloud URL for your appEXPO_PUBLIC_CONVEX_SITE_URL— The URL for Convex HTTP actions (used for auth)
Frontend: apps/default/
Your Expo app lives here. It’s a universal React Native app that runs on iOS, Android, and web from a single codebase.
App Directory
Theapp/ folder uses Expo Router for file-based routing. Each file becomes a route.
- _layout.tsx
- index.tsx
The root layout wraps your entire app with required providers:
- ConvexProvider — Connects your app to the Convex backend
- ConvexBetterAuthProvider — Manages authentication state
- Stack — The navigation container for your screens
Key Configuration Files
app.json
app.json
Expo configuration file that defines your app’s name, icons, splash screen, and platform-specific settings.
lib/auth-client.ts
lib/auth-client.ts
Configures the Better Auth client for authentication. Handles platform-specific storage (secure store on native, cookies on web) and cross-domain authentication.
tsconfig.json
tsconfig.json
TypeScript configuration with path aliases for cleaner imports:
@/*— Maps to the current directory@/convex/*— Maps to../../packages/backend/convex/*
Backend: packages/backend/convex/
Your Convex backend contains your database schema, serverless functions, and authentication logic.
Core Files
- schema.ts
- functions.ts
- auth.ts
- http.ts
Defines your database tables and their structure. Convex uses this to generate type-safe queries.Changes to your schema automatically sync with your database.
Generated Files
The_generated/ folder contains auto-generated TypeScript types. These are created by Convex and should not be edited manually.
| File | Purpose |
|---|---|
api.d.ts | Type-safe references to your functions |
dataModel.d.ts | Types matching your database schema |
server.d.ts | Server-side types for queries and mutations |
These files update automatically when you modify your schema or functions. They enable full type safety between your frontend and backend.
Key Patterns
Environment Variables
Environment variables flow through your app in a specific way:- Defined in
.envat the project root - Backend reads them via the
--env-fileflag - Frontend loads them through Metro bundler using
@expo/env - Variables prefixed with
EXPO_PUBLIC_are available in frontend code
Type-Safe Imports
The path alias@/convex/* lets your frontend import backend types directly:
Authentication Flow
Authentication is pre-wired between frontend and backend:- Frontend uses
authClientfromlib/auth-client.ts - Auth requests route through Convex HTTP endpoints
- Session state syncs via
ConvexBetterAuthProvider - Backend functions access the user via
ctx.session

