Getting Started
Install packages, mount the inspector, enable transforms, and register middleware.
Getting Started
Use the same launch URL everywhere: the <Inspector /> prop
customLaunchEditorEndpoint, the middleware customLaunchEditorEndpoint, and
(for Next) withNextInspector({customLaunchEditorEndpoint}) must match. The
shared default in @hyperse/inspector-common is /__hps_inspector.
Install packages
npm install @hyperse/inspector @hyperse/inspector-middlewarePick one compile-time integration:
- Babel:
@hyperse/inspector-babel-plugin - SWC:
@hyperse/inspector-swc-plugin
For Next.js, also install:
npm install @hyperse/next-inspectorRender <Inspector /> (development only)
import { Inspector } from '@hyperse/inspector';
export function App() {
const isDev = process.env.NODE_ENV === 'development';
return (
<>
{isDev ? <Inspector /> : null}
{/* your app */}
</>
);
}Optional props include keys, active / onActiveChange, hideDomPathAttr,
onInspectElement, and customLaunchEditorEndpoint. See
Inspector component.
Enable the transform (dev only)
- Babel: add
@hyperse/inspector-babel-pluginwhenNODE_ENV === 'development'. - SWC: register the wasm plugin under
jsc.experimental.pluginsfor dev builds.
See Babel plugin and SWC plugin.
Register dev-server middleware
Use createLaunchEditorMiddleware from @hyperse/inspector-middleware on your
dev server. Examples:
Verify your editor CLI
Ensure code, cursor, webstorm, or your chosen CLI is on PATH, or set
LAUNCH_EDITOR / EDITOR before starting the dev server.