Docs/Hooks

Hooks

There are a plethora of hooks available for you to use in the server during page build.

Build Hooks

Build hooks let you run callbacks and manipulate output during a build of your page.

Here is a list of available build hooks:

ts
export function getOutputDirectory(): string

/**
 * Runs `callback` before the compilation of *this build instance* of this
 * page once per rebuild in dev mode, once per build in prod.
 * For dynamic pages this is of course called for every build.
 */
export function preBuildHook(callback: () => Promise<void>): void

/**
 * Runs `callback` after the compilation of *this build instance* of this
 * page once per rebuild in dev mode, once per build in prod.
 * For dynamic pages this is of course called for every build.
 */
export function postBuildHook(callback: () => Promise<void>): void

/**
 * Runs `callback` exactly once per page.ts file for the lifetime of the
 * process, regardless of how many times the page is rebuilt.
 * It is called before the build of this page.
 */
export function buildCallback(callback: () => Promise<void>): void

/**
 * Schedules `input` to be copied to `target` (relative to the output
 * directory) as part of the post-build step for this page instance.
 */
export function publishFile(input: string, target: string): void