Getting Started
Authoring
Access Control
Reference
Examples
Hooks, pipelines & integrations
Hooks, pipelines & integrations
Collection server behavior lives beside its model in recognized role files. Pod discovers each role automatically and generates its exact registry-aware type.
Hooks
Create src/collections/<name>/+hooks.ts. Before hooks validate and return the
accepted input or patch. After hooks perform same-transaction side effects.
import type { Hooks } from './$types.js';
export default {
create: {
before: async ({ input, api }) => {
const count = await api.db.sites.count({ where: { name: { eq: input.name } } });
if (count) throw new Error('Site already exists.');
return input;
}
}
} satisfies Hooks; Pipelines
Create +pipelines.ts for canonical collection import and export behavior. The tenant collection
UI, agents, and integrations reuse the same contract.
import type { Pipelines } from './$types.js';
import { exportPipeline } from './lib/export.js';
export default { export: exportPipeline } satisfies Pipelines; Integrations
Create +integrations.ts to bind external receive/send behavior to the collection. Connections
and secret values remain host facilities; tenant source declares requirements only.
Choose the narrowest role
- Hooks — mutation invariants and same-transaction effects
- Pipelines — reusable bulk ingest and artifact contracts
- Integrations — reliable external delivery that reuses pipelines
- Automations — scheduled or event-driven background jobs
- Remotes — dedicated typed server entrypoints called by apps