Cookbook Router

Choose a plugin

Choose the supported adapter that matches the build lifecycle and watch behavior you actually need.

Decision table

EnvironmentUseNew matching route files discovered in native watch mode?Failure behavior
Vite dev/buildVite pluginYesDev logs and remains recoverable; production build throws
WebpackWebpack pluginYesNormal build throws; watch mode keeps previous valid output and retries
RspackRspack pluginYesSame compiler-hook contract as Webpack
Rollup/RolldownRollup pluginYes, through addWatchFile() rootsWatch warns and retries; non-watch build fails
esbuildesbuild pluginNot through this adapterReturns an esbuild errors entry from onStart
Bun bundlerBun pluginNot through this adapterThrows from Bun onStart

What “discovered” means

Watching the files that already exist is not enough. A route plugin also has to watch stable glob roots and config candidates so that creating the first matching file, deleting the last one, or repairing a broken config triggers another run.

Vite, Webpack, Rspack, and Rollup can register those roots with their host bundler. The current esbuild and Bun adapters only run at build start; they cannot add equivalent dynamic route-root watches through their plugin APIs. Pair them with cbr generate --watch during development when new route-file discovery matters.

Rolldown

Use the Rollup package. Its public adapter is implemented against the Rollup-compatible plugin contract and is explicitly named for Rollup/Rolldown support.

On this page