ForgeKit Stable v1.0 is officially released. Upgrade now for zero-assertions DB compilation. Read Release Notes
Docs Nav

@forgekit/core

@forgekit/core is the foundational kernel that binds all toolkit modules together. It manages plugin lifecycles, configuration contexts, and middleware pipelines.

Constructor API Reference

To instantiate a ForgeKit application instance:

import { ForgeApp } from '@forgekit/core';

const app = new ForgeApp(config?: ForgeAppConfig);

Config Options

PropertyTypeDefaultDescription
debugbooleanfalseEnable detailed execution logging
environment'development' \| 'production''development'Runtime node configuration state

Plugin Middleware Pipeline

The use() method registers plugin layers (such as @forgekit/db or @forgekit/auth) and makes them available on the core app context:

import { ForgeApp } from '@forgekit/core';
import { db } from '@forgekit/db';

const app = new ForgeApp();
app.use(db({ url: 'postgres://...' }));

// The plugin adds property bindings directly
const users = await app.db.query('SELECT * FROM users');

Lifecycle Hooks

Plugins can register hooks to run at specific stages of the request/response lifecycle:

  • onInit: Fired when the ForgeApp class instantiates.
  • onBeforeRequest: Runs prior to handling incoming request sessions.
  • onAfterResponse: Executed after generating outbound responses.