Skip to content

@reatom/vite

@reatom/vite

Vite plugin that automatically handles Reatom routing HMR and @reatom/jsx mount HMR.

Installation

Terminal window
npm install -D @reatom/vite

Usage

import { defineConfig } from 'vite'
import { reatom } from '@reatom/vite'
export default defineConfig({
plugins: [reatom()],
})

In development the plugin:

  1. Routes — tracks reatomRoute(...) / parent.reatomRoute(...) calls; on hot dispose removes the old child from parent.routes / urlAtom.routes and retryComputed(parent.outlet), then retries the parent outlet again after each new route is registered (plain routes objects do not invalidate outlet on their own).
  2. JSX — tracks mount(...) from @reatom/jsx, then on hot dispose calls unmount() so the re-executed module can mount a fresh tree.

Modules that already contain import.meta.hot are left untouched so manual HMR keeps working.

Options

reatom({
routes: true, // default
jsx: true, // default
include: [/src\//],
exclude: [/stories\//],
})