Documentation Index
Fetch the complete documentation index at: https://mintlify.com/amanvarshney01/create-better-t-stack/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Better-T-Stack uses a flexible template system powered by Handlebars to generate project files based on your configuration. Templates live inpackages/template-generator/templates/ and are processed at build time to create your project structure.
Template Location
All templates are stored in the monorepo at:Handlebars Syntax
Templates use.hbs extension and support Handlebars expressions:
Basic Variables
{ projectName: "my-app", packageManager: "bun" }, this generates:
Conditionals
Templates use custom helpers for conditional logic:Template Helpers
Custom helpers are registered inpackages/template-generator/src/core/template-processor.ts:6-10:
These helpers must be called with parentheses:
{{#if (eq orm "drizzle")}} not {{#if eq orm "drizzle"}}Real Template Examples
Complex Conditional Logic
Frompackages/template-generator/templates/packages/infra/alchemy.run.ts.hbs:1-26:
This template generates different imports based on deployment targets and frontend choices, demonstrating the power of conditional templating.
Nested Conditionals with Multiple Variables
From the same file (lines 54-98), showing environment variable bindings:File Naming Conventions
.hbs Extension
Files ending in.hbs are processed as Handlebars templates. The extension is removed in the output:
Special Filenames
Certain filenames are transformed:- Transformed
- Reason
_gitignore→.gitignore_npmrc→.npmrc
Escaping Handlebars
When template files need to contain literal{{ }} syntax (common in Vue, JSX, or other template languages), escape the opening braces:
\{{ becomes {{ in the output.
Template Processing Flow
Template selection
CLI determines which template directories to include based on config (e.g., if
database: "postgres" and orm: "drizzle", include templates/db/drizzle/postgres/)File tree generation
Templates are read, processed through Handlebars with config as context, and assembled into virtual file tree
Code Reference
Fromapps/cli/src/helpers/core/create-project.ts:52-67:
Available Context
Templates receive aProjectConfig object with these fields:
Project name
Absolute path to project directory
Relative path from current directory
Frontend frameworks (e.g.,
["next"], ["tanstack-router"])Backend framework:
hono, express, fastify, elysia, convex, self, noneRuntime:
bun, node, workers, noneDatabase:
sqlite, postgres, mysql, mongodb, noneORM:
drizzle, prisma, mongoose, noneAPI layer:
trpc, orpc, noneAuth provider:
better-auth, clerk, nonePayment integration:
polar, noneAddons:
["turborepo", "pwa"], etc.Examples:
["todo", "ai"], etc.Database hosting:
turso, neon, docker, etc.Web deployment:
cloudflare, noneServer deployment:
cloudflare, nonePackage manager:
npm, pnpm, bunInitialize git repository
Install dependencies
Template Organization Best Practices
Keep templates DRY
Keep templates DRY
Share common logic across templates using Handlebars partials or by extracting to base templates.
Use meaningful conditionals
Use meaningful conditionals
Prefer checking the actual config value rather than complex combinations:Good:Avoid:
Comment complex logic
Comment complex logic
Add comments to explain non-obvious conditional chains:
Test edge cases
Test edge cases
Ensure templates work for all valid combinations of config values. The CLI includes tests in
apps/cli/test/basic-configurations.test.ts.Binary Files
Binary files (images, fonts, etc.) are detected and copied without template processing:templates/addons/pwa/apps/web/next/public/favicon/apple-touch-icon.pngtemplates/addons/pwa/apps/web/vite/public/logo.png
Debugging Templates
To see generated output during development:Related
Project Structure
See what templates generate
Contributing
Add new templates to Better-T-Stack