SaaS Starter Kit for CanxJS - Multi-tenancy, Billing, Team Management
npm install canx-starter-saas/canx-queue
bash
Clone the starter
bunx degit chandafa/canx-starters/saas my-saas
Install dependencies
cd my-saas
bun install
Start development server
bun run dev
`
Project Structure
`
src/
āāā controllers/
ā āāā AuthController.ts # Login/register with team
ā āāā BillingController.ts # Subscription & invoices
ā āāā DashboardController.ts # Main dashboard
ā āāā HomeController.ts # Landing & pricing
ā āāā TeamController.ts # Team management
āāā middleware/
ā āāā tenant.ts # Multi-tenancy middleware
āāā views/
ā āāā layouts/
ā āāā saas.ts # App layout
āāā routes.ts # Route definitions
āāā app.ts # Application entry
`
Multi-Tenancy
Tenants are identified by:
1. Subdomain: acme.yourdomain.com ā tenant: acme
2. Header: X-Tenant-Id: acme
Access tenant in controllers:
`typescript
const tenant = this.request.context.get("tenant");
console.log(tenant.id); // "acme"
`
Available Routes
| Route | Description |
| ---------------- | ----------------------- |
| / | Landing page |
| /pricing | Pricing page |
| /auth/login | Login |
| /auth/register | Register + create team |
| /dashboard | Main dashboard |
| /team | Team management |
| /billing | Subscription & invoices |
Stripe Integration
To integrate Stripe:
1. Install Stripe: bun add stripe
2. Set environment variables:
`env
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
`
3. Update BillingController.ts` with Stripe checkout