IntegrationsEdit this page.md

React

@lazarv/react-server ships with React built-in. You do not need to install react or react-dom yourself — the runtime includes the correct experimental version of React that supports React Server Components, server actions, and all the latest React features.

React Server Components require an experimental build of React that includes the RSC wire protocol, server references, and streaming support. These experimental APIs are not available in the stable releases published to npm. By bundling the exact React version it was built against, @lazarv/react-server guarantees:

When you create a project with @lazarv/react-server, your package.json should not list react or react-dom as dependencies:

./package.json
{ "dependencies": { "@lazarv/react-server": "latest" } }

That's it. The runtime provides React for your entire project — server components, client components, and SSR.

If you are migrating from an existing React project, remove react and react-dom from your dependencies:

pnpm remove react react-dom

@lazarv/react-server lists react, react-dom, and react-server-dom-webpack as direct dependencies (not peer dependencies). At both development and build time, the runtime sets up module aliases so that any import of react or react-dom — whether from your code or from third-party libraries — resolves to the React version bundled with the runtime.

This aliasing operates at the Vite module resolution level across all three environments:

Because the aliasing intercepts resolution before any bundling happens, third-party libraries that import from react or react-dom will transparently use the runtime's React — no configuration needed.

Most React libraries work out of the box with @lazarv/react-server. The key compatibility considerations are:

Libraries that work seamlessly

Any library that depends on react or react-dom via standard imports will work, because module aliasing ensures it receives the runtime's React. This includes:

Client vs. server components

Third-party libraries that use React hooks (useState, useEffect, useRef, etc.) or browser APIs must be used inside client components (files with "use client" directive). This is a React Server Components rule, not a @lazarv/react-server limitation.

./src/Counter.jsx
"use client"; import { useState } from "react"; import { motion } from "framer-motion"; export default function Counter() { const [count, setCount] = useState(0); return ( <motion.button whileTap={{ scale: 0.95 }} onClick={() => setCount(count + 1)} > count is {count} </motion.button> ); }

Server components can import and render client components, but cannot use hooks or browser APIs themselves. See the client components guide and server components guide for more details.

Libraries with React version checks

Some libraries perform runtime version checks (e.g., reading React.version). Since @lazarv/react-server uses an experimental React build, the version string looks like 0.0.0-experimental-... rather than a stable 19.x.x. Most libraries handle this gracefully, but in rare cases a library might warn or refuse to load because it doesn't recognize the version.

If you encounter this, the library usually still works correctly — the warning can be safely ignored. If a library strictly blocks on version, check whether a newer version of that library has relaxed its version check, or open an issue with the library maintainer.

Libraries that bundle their own React

Occasionally, a library might bundle its own copy of React instead of importing it as a peer dependency. This can cause the "multiple React instances" problem — hooks errors (Invalid hook call) or context not being shared. However, @lazarv/react-server already deduplicates react and react-dom automatically, so most of these cases are handled for you without any extra configuration.

For TypeScript users, you should use the experimental React types in your tsconfig.json:

./tsconfig.json
{ "compilerOptions": { "types": ["react/experimental", "react-dom/experimental"] } }

This ensures your editor recognizes the latest React APIs like "use client", "use server", useActionState, useFormStatus, and other experimental features. See the TypeScript integration guide for a complete configuration example.

To see which React version @lazarv/react-server is using, you can check it at runtime:

import { version } from "react"; export default function Version() { return <p>React version: {version}</p>; }

Or inspect the installed version via the CLI:

node -e "console.log(require('@lazarv/react-server/node_modules/react/package.json').version)"