LogoRobo.js
Framework

HmrContext

Interface: HmrContext

Context provided to HMR hooks. Runs in PARALLEL with a 5-second timeout. Hook errors are caught and logged but never crash the server.

Example

// src/robo/hmr.ts
import type { HmrContext } from 'robo.js'

export const config = {
  namespaces: ['server'],
  routes: ['api']
}

export default async function (context: HmrContext) {
  context.logger.info(`HMR: ${context.changeType} - ${context.files.join(', ')}`)
  // Custom logic: clear caches, notify services, etc.
}

Properties

PropertyTypeDescription
changeType"change" | "add" | "remove"Type of file system change that triggered HMR. - 'change': File was modified - 'add': New file was added - 'remove': File was deleted
envtypeof EnvEnvironment variable access.
filesstring[]Source files that changed (relative paths from project root). Example ['src/api/users.ts', 'src/api/posts.ts']
loggerLoggerLogger instance (forked for plugins).
modestringCurrent runtime mode (e.g., 'development', 'production').
routesHmrRouteInfo[]Routes affected by the HMR event. Already filtered by hook's config.namespaces and config.routes if specified.

On this page