rolldown-plugin-react-forward-ref weekly downloads statistics
By diegohaz · npm · Vite plugins
Transform React ref props into forwardRef components for React 18 with Rolldown and Vite.
rolldown-plugin-react-forward-ref has 4,559 recorded weekly downloads on npm, a decrease of 63.4% over the past 30 days, ranking #1566 of 3,247 tracked listings.
About rolldown-plugin-react-forward-ref
rolldown-plugin-react-forward-ref
Run selected React 19-style function components on React 18. The plugin adds
forwardRef wrappers at module initialization and passes the received ref to the
original function as a prop. It supports indirect forwarding:
export function Button(props: ButtonProps) {
const [variantProps, rest] = splitProps(props, button);
return <BaseButton {...button.jsx(variantProps)} {...rest} />;
}
The ref reaches splitProps before the function reads props. There is no extra
React element around the original function, and wrappers keep their identity
across renders. This package adapts ref transport only. It does not polyfill
other React 19 features.
Install it as a development dependency:
pnpm add -D rolldown-plugin-react-forward-ref
API and file selection
import reactForwardRef from "rolldown-plugin-react-forward-ref";
reactForwardRef({
include: ["src/components/**/*.tsx", "src/examples/**/*.tsx"],
exclude: ["**/*.test.tsx", "**/legacy/**"],
});
include is required and must be a non-empty glob, regular expression, or array
of those patterns. exclude accepts the same forms and takes priority. Globs
use @rollup/pluginutils and resolve relative to process.cwd(). Paths use
forward slashes on all platforms. There are no project-specific path defaults.
Only .js, .jsx, .ts, .tsx, .mjs, .mts, .cjs, .cts, are eligible. Declaration files, virtual modules, node_modules, and
Vite ?raw/?url requests are always excluded. JSX in JavaScript files is parsed;
the host must also be configured to lower JSX for the selected extension. Other query suffixes are removed
before matching. Input must be an ES module; the plugin does not convert CommonJS
module exports.
There is one default export for Rolldown, Vite, and Vitest. The plugin uses a
transform hook, with order: "pre" and Vite's enforce: "pre". It runs before
TypeScript/JSX lowering, in both development and builds. Put it before other
plugins with pre-transform hooks, including @vitejs/plugin-react. Already
lowered JSX cannot be detected.
Version selection belongs to the consumer configuration. The plugin does not read a React version or enable itself automatically.
Rolldown
import { defineConfig } from "rolldown";
import reactForwardRef from "rolldown-plugin-react-forward-ref";
export default defineConfig({
input: "src/index.tsx",
plugins: [reactForwardRef({ include: "src/components/**/*.tsx" })],
external: /^react(?:\/|$)/,
output: { dir: "dist", format: "esm", sourcemap: true },
});
Vite
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import reactForwardRef from "rolldown-plugin-react-forward-ref";
export default defineConfig({
plugins: [reactForwardRef({ include: "src/components/**/*.tsx" }), react()],
});
React 18-only Vitest configuration
Read the version from the test workspace's dependency graph. An isolated React 18 workspace must install matching React and React DOM versions.
import react from "@vitejs/plugin-react";
import { version } from "react";
import { defineConfig } from "vitest/config";
import reactForwardRef from "rolldown-plugin-react-forward-ref";
export default defineConfig({
plugins: [
version.startsWith("18.") &&
reactForwardRef({
include: ["src/ui/**/*.tsx", "src/examples/**/*.tsx"],
}),
react(),
],
test: { environment: "jsdom" },
});
For projects that alias React, use an explicit target flag instead if the
configuration's react import does not resolve to the test runtime. Disable the
plugin for React 19 to retain its native behavior. The test suite also checks
adapted output on React 19, with the no-ref semantics below.
Component selection
Within each selected file, the plugin selects top-level function declarations
and const function initializers with an ASCII uppercase first letter and JSX
in their own function body. A default-exported function can have any name or be
anonymous, except names with the hook prefix use followed by an uppercase
letter or digit. JSX in nested functions or classes does not count. A visible ref
read is not required. Hooks and ordinary lowercase utilities stay unchanged.
This is a syntax rule, not proof that a function is a React component. Limit the
file filters to component source. A PascalCase utility with JSX that otherwise
meets the rule is indistinguishable from a component. Functions used as direct
calls, constructors, .call/.apply/.bind targets, or arguments to opaque
functions are conservatively left unchanged. This also protects render functions
passed to existing forwardRef calls or custom HOCs. Local identifier aliases
are followed; this conservative check can also skip a same-named binding in
another scope.…
Description from the npm listing.
- forwardref
- react
- react18
- rolldown
- rolldown-plugin
- vite
- vite-plugin
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (170)Similar npm Vite plugins plugins
All 20 rolldown-plugin-react-forward-ref alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/rolldown-plugin-react-forward-ref. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.