Mixed client/server barrels
What a mixed-client-server-barrel finding of fallow dead-code means, why it matters and how to fix it.
What it reports
Barrel re-exports both a "use client" module and a server-only module.
Architecture explains how fallow finds it.
Why it matters
A barrel file (a module whose exports are export ... from re-exports) forwards a name from a "use client" module alongside a name from a server-only module (one carrying "use server", importing the server-only package, or importing a server-only Next.js API such as next/headers). Importing one name from such a barrel drags the other's directive context across the React Server Components boundary, a known Next.js App Router problem. Type-only re-exports are ignored (erased at build), and a barrel re-exporting a client module alongside an ordinary undirected utility is not reported. To fix: split the barrel so client and server-only modules are re-exported from separate entry points. The check runs only when the project declares a React Server Components bundler: next, waku, @lazarv/react-server, react-server-dom-webpack, react-server-dom-vite, react-server-dom-parcel or @vitejs/plugin-rsc.
Example
components/index.ts re-exports Button from a "use client" module and getUser from a module that imports server-only.
Fix
Split the barrel: re-export the client modules from one file and the server-only modules from another file.
Facts
| Fact | Value |
|---|---|
| Issue type | mixed-client-server-barrel |
| Rule id in SARIF output | fallow/mixed-client-server-barrel |
| Command | fallow dead-code |
| Default severity | warn |
Config key in rules | mixed-client-server-barrel |
| Suppression comment | // fallow-ignore-next-line mixed-client-server-barrel |
Fixable with fallow fix | No |
| Opt-in | No |
Note. Requires the project to declare a React Server Components bundler, such as next, waku or @vitejs/plugin-rsc.
When to keep the code
- When the grouping is intentional, suppress the finding with
// fallow-ignore-next-line mixed-client-server-barrel.
Notes
The rule runs when the project declares a bundler for React Server Components: next, waku, @lazarv/react-server, @vitejs/plugin-rsc or a react-server-dom-* package. Fallow does not report a barrel that mixes a client file with a file without a directive.