Function: initFusion()
ts
function initFusion<TContext>(): FusionInstance<TContext>;Defined in: packages/core/src/core/initFusion.ts:346
Initialize a Fusion instance with a fixed context type.
Call once per project. All factory methods on the returned instance automatically inherit the context type — zero generic repetition.
Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
TContext | void | The application-level context type |
Returns
FusionInstance<TContext>
A FusionInstance with context-typed factories
Example
typescript
// Single definition, typically in src/fusion.ts
export const f = initFusion<AppContext>();
// Build tools with the Fluent API
const listUsers = f.query('users.list')
.describe('List all users')
.withOptionalNumber('limit', 'Max results (default: 50)')
.handle(async (input, ctx) => {
return ctx.db.users.findMany({ take: input.limit ?? 50 });
});