Installation Guide
Install Fabric in your project to start generating TypeScript code, API clients, or configuration files programmatically.
Time to install: < 1 minute
Requirements: Node.js 20+ or Bun 1.0+
Install Fabric Core
The core package provides Fabric's file generation engine with a lightweight custom JSX renderer (FSX). No React dependency required.
Use Fabric Core when:
- You want minimal dependencies
- You don't need React integration
- You prefer imperative TypeScript code
Install command:
bun add -d @kubb/fabric-corepnpm add -D @kubb/fabric-corenpm install --save-dev @kubb/fabric-coreyarn add -D @kubb/fabric-coreInstall React Fabric (Optional)
The React integration package lets you use React components and standard JSX for code generation templates.
Use React Fabric when:
- You want familiar React/JSX patterns
- Your project already uses React
- You prefer component-based templates
Install command:
bun add -d @kubb/react-fabricpnpm add -D @kubb/react-fabricnpm install --save-dev @kubb/react-fabricyarn add -D @kubb/react-fabricNOTE
The @kubb/react-fabric package includes @kubb/fabric-core as a dependency, so you do not need to install both packages separately.
System Requirements
Fabric requires Node.js 20 or higher, or Bun 1.0 or higher.
| Node.js: | >= 20 |
|---|---|
| Bun: | >= 1.0 |
TypeScript Configuration
Fabric is written in TypeScript and provides full type definitions. You should configure your TypeScript project with module: "ESNext" or module: "NodeNext" since Kubb prefers ESM.
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "bundler",
"target": "ES2022",
"lib": ["ES2023"]
}
}NOTE
@kubb/react-fabric includes @kubb/fabric-core as a dependency. You don't need to install both separately.
Verify Your Installation
Test that Fabric is installed correctly by creating a simple verification script.
Create test-fabric.ts:
import { createFabric } from '@kubb/fabric-core'
const fabric = createFabric()
console.log('Fabric initialized successfully!')Run the verification:
bun test-fabric.tsnode --loader tsx test-fabric.tsExpected output:
Fabric initialized successfully!Next Steps
- Quick Start - Build your first code generator
- Configuration - Set up plugins and parsers
- Core API - Explore Fabric components
Troubleshooting
Module Not Found Error
If you see Cannot find module '@kubb/fabric-core':
Verify installation:
bashnpm list @kubb/fabric-coreCheck package.json has ESM enabled:
json{ "type": "module" }Reinstall dependencies:
bashrm -rf node_modules package-lock.json npm install
TypeScript Errors
If TypeScript shows module resolution errors, ensure your tsconfig.json uses ESM:
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "bundler"
}
}More help: See the Troubleshooting Guide
FAQ
Which package should I install?
- Install
@kubb/fabric-corefor most use cases - Install
@kubb/react-fabriconly if you want React/JSX template support
Do I need React installed?
No, unless you use @kubb/react-fabric. The core package has no React dependency.
What Node.js version is required?
Node.js 20 or higher is required for ESM support. Check your version:
node --version # Should show v20.0.0 or higherCan I use Fabric with Bun?
Yes. Fabric works with Bun 1.0 or higher. Bun natively supports TypeScript and ESM.
Related Resources
- Introduction - Learn about Fabric architecture
- System Requirements - Check compatibility
- TypeScript Configuration - Configure TypeScript properly
