react-refresh-typescript is a TypeScript transformer that integrates React Fast Refresh (Hot Module Replacement) into React applications. It specifically handles the necessary transformations for TypeScript codebases to enable live editing of React components without losing their state. The package is currently under on-demand maintenance, meaning updates typically occur when issues are opened to track upstream changes in `react-refresh`. It currently matches `react-refresh@0.19.*` (React 19). Its primary audience includes bundler plugin developers, such as those building integrations for webpack, Rollup, or esbuild. Key differentiators include its direct integration as a TypeScript custom transformer, which allows it to operate early in the compilation pipeline, and its support for Deno environments. This package is essential for enabling a smooth developer experience with hot reloading in TypeScript-based React projects.
npm install react-refresh-typescriptVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use react-refresh-typescript with TypeScript's `transpileModule` API to transform React JSX code for Fast Refresh.
Ensure your `tsconfig.json` `compilerOptions.module` is set to `es2015`, `esnext`, `es2020`, `es2022`, or `nodenext`.
If you encounter issues with newer `react-refresh` versions, open an issue on the GitHub repository to prompt an update.
Configure an `import_map.json` in Deno to map `typescript` (e.g., to `https://esm.sh/typescript`) or import `dist-src/core.js` and provide `ts` in the options object directly.
Pass an `Options` object to `refresh()` if you need to customize `refreshReg`, `refreshSig`, `emitFullSignatures`, `ts` instance, or `hashSignature`.
Change `compilerOptions.module` in your `tsconfig.json` to `es2015` or a newer ES module target.
Change your import statement from `import { refresh } from 'react-refresh-typescript';` to `import refresh from 'react-refresh-typescript';`