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.
The Better-T-Stack CLI can be used programmatically from TypeScript/JavaScript applications. This enables integration with build tools, automation scripts, CI/CD pipelines, and custom generators.
Installation
Install as a package dependency:
npm install create-better-t-stack
Core API Functions
The programmatic API exports the following functions:
create() Create a new Better-T-Stack project on disk
createVirtual() Generate a project in-memory (virtual filesystem)
add() Add addons to an existing project
Types TypeScript types and interfaces
Key Concepts
Silent Mode
All programmatic API functions run in silent mode :
No interactive prompts
No CLI UI output
No process exits
Returns typed results instead
Result Type
The API uses the Result type from better-result for type-safe error handling:
import { create } from "create-better-t-stack" ;
const result = await create ( "my-app" , {
frontend: [ "tanstack-router" ],
backend: "hono" ,
database: "sqlite" ,
orm: "drizzle" ,
});
result . match ({
ok : ( data ) => console . log ( `Created at: ${ data . projectDirectory } ` ),
err : ( error ) => console . error ( `Failed: ${ error . message } ` ),
});
Use Cases
Generate projects in CI/CD pipelines: import { create } from "create-better-t-stack" ;
// In your CI script
const result = await create ( "test-app" , {
frontend: [ "tanstack-router" ],
backend: "hono" ,
runtime: "bun" ,
database: "sqlite" ,
orm: "drizzle" ,
git: false ,
install: true ,
});
if ( result . isErr ()) {
process . exit ( 1 );
}
Use virtual filesystem for testing and web previews: import { createVirtual } from "create-better-t-stack" ;
const result = await createVirtual ({
frontend: [ "tanstack-router" ],
backend: "hono" ,
database: "sqlite" ,
orm: "drizzle" ,
});
result . match ({
ok : ( tree ) => {
console . log ( `Generated ${ tree . fileCount } files` );
// Render file tree in UI
},
err : ( error ) => console . error ( error . message ),
});
Build custom project generators: import { create , add } from "create-better-t-stack" ;
async function generateCustomStack ( name : string ) {
// Create base project
const createResult = await create ( name , {
frontend: [ "next" ],
backend: "hono" ,
database: "postgres" ,
orm: "drizzle" ,
auth: "better-auth" ,
});
if ( createResult . isErr ()) {
return createResult ;
}
// Add custom addons
await add ({
projectDir: createResult . value . projectDirectory ,
addons: [ "biome" , "mcp" ],
install: true ,
});
return createResult ;
}
Quick Example
Here’s a complete example:
import { create , Result } from "create-better-t-stack" ;
const result = await create ( "my-app" , {
frontend: [ "tanstack-router" ],
backend: "hono" ,
runtime: "bun" ,
database: "sqlite" ,
orm: "drizzle" ,
auth: "better-auth" ,
addons: [ "biome" ],
packageManager: "bun" ,
install: false ,
});
result . match ({
ok : ( data ) => {
console . log ( `Project created at: ${ data . projectDirectory } ` );
console . log ( `Time taken: ${ data . elapsedTimeMs } ms` );
console . log ( `Reproducible command: ${ data . reproducibleCommand } ` );
},
err : ( error ) => {
console . error ( `Failed: ${ error . message } ` );
process . exit ( 1 );
},
});
// Or use unwrapOr for a default value
const data = result . unwrapOr ( null );
if ( data ) {
console . log ( data . projectDirectory );
}
Next Steps
create() Learn about the create() function
Error Handling Handle errors properly
Types Reference Explore all available types
Examples See complete examples