Skip to main content

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 add() function adds addons to an existing Better-T-Stack project. It integrates additional tools and features into your project configuration.

Signature

function add(
  options?: {
    addons?: Addons[];
    install?: boolean;
    packageManager?: PackageManager;
    projectDir?: string;
  }
): Promise<AddResult | undefined>
Source: ~/workspace/source/apps/cli/src/index.ts:359

Parameters

options
object
Configuration options for adding addons. All fields are optional.

Return Type

Promise<AddResult | undefined>
Returns undefined if the operation was cancelled, otherwise returns AddResult:
success
boolean
required
Whether the operation succeeded
addedAddons
Addons[]
required
List of addons that were successfully addedExample: ["biome", "playwright"]
projectDir
string
required
Absolute path to the project directoryExample: "/Users/name/my-app"
error
string
Error message if success is falseExample: "Invalid addon: unknown-addon"

Examples

Basic Usage

import { add } from "create-better-t-stack";

const result = await add({
  addons: ["biome", "playwright"],
  install: true,
});

if (result?.success) {
  console.log(`Added: ${result.addedAddons.join(", ")}`);
} else {
  console.error(result?.error ?? "Failed to add addons");
}

Add to Specific Project

import { add } from "create-better-t-stack";

const result = await add({
  projectDir: "./my-app",
  addons: ["husky", "mcp"],
  packageManager: "bun",
  install: true,
});

if (result?.success) {
  console.log(`Added to ${result.projectDir}`);
  console.log(`Addons: ${result.addedAddons.join(", ")}`);
}

Add Without Installing

import { add } from "create-better-t-stack";

// Add addons but skip dependency installation
const result = await add({
  addons: ["biome"],
  install: false,
});

if (result?.success) {
  console.log("Added Biome (dependencies not installed)");
  console.log("Run 'bun install' to install dependencies");
}

Error Handling

import { add } from "create-better-t-stack";

const result = await add({
  addons: ["biome", "playwright"],
  install: true,
});

if (!result) {
  console.log("Operation was cancelled");
  process.exit(0);
}

if (!result.success) {
  console.error(`Error: ${result.error}`);
  process.exit(1);
}

console.log(`Successfully added: ${result.addedAddons.join(", ")}`);

Combined with create()

import { create, add } from "create-better-t-stack";

// First create a project
const createResult = await create("my-app", {
  frontend: ["tanstack-router"],
  backend: "hono",
  database: "sqlite",
  orm: "drizzle",
});

if (createResult.isErr()) {
  console.error("Failed to create project");
  process.exit(1);
}

// Then add addons
const addResult = await add({
  projectDir: createResult.value.projectDirectory,
  addons: ["biome", "playwright", "husky"],
  install: true,
});

if (addResult?.success) {
  console.log(`Project ready at: ${createResult.value.projectDirectory}`);
  console.log(`With addons: ${addResult.addedAddons.join(", ")}`);
}

Multiple Addons

import { add } from "create-better-t-stack";

const result = await add({
  addons: [
    "biome",      // Formatter/linter
    "playwright",  // Testing
    "husky",       // Git hooks
    "posthog",     // Analytics
  ],
  install: true,
  packageManager: "bun",
});

if (result?.success) {
  console.log(`Added ${result.addedAddons.length} addons`);
}

Check What Was Added

import { add } from "create-better-t-stack";

const result = await add({
  addons: ["biome", "playwright"],
});

if (result?.success) {
  // Check which addons were actually added
  const hasBiome = result.addedAddons.includes("biome");
  const hasPlaywright = result.addedAddons.includes("playwright");
  
  console.log(`Biome added: ${hasBiome}`);
  console.log(`Playwright added: ${hasPlaywright}`);
  
  // List all added addons
  result.addedAddons.forEach(addon => {
    console.log(`✓ ${addon}`);
  });
}

Available Addons

Biome

Fast formatter and linter for JavaScript/TypeScript

Playwright

End-to-end testing framework

Husky

Git hooks for pre-commit and pre-push automation

MCP

Model Context Protocol server integration

Alchemy

Alchemy SDK for blockchain development

PWA

Progressive Web App support with offline capabilities

PostHog

Product analytics and feature flags

What Gets Modified

When you add an addon, the following may be modified:
  1. Dependencies - Added to package.json
  2. Configuration Files - Addon-specific config files (e.g., biome.json, playwright.config.ts)
  3. Scripts - Package scripts updated in package.json
  4. Project Config - bts.jsonc updated with added addons
  5. Setup Files - Integration files added (e.g., hooks, middleware)

Notes

The add() function must be run in a directory containing a bts.jsonc file (a Better-T-Stack project).
If install is true and no packageManager is specified, it will be auto-detected from the project’s lock files.
Some addons may have dependencies on other project features. For example, the Alchemy addon requires a database to be configured.

Build docs developers (and LLMs) love