{"record":{"id":"c7b6844e7cc8e8c7","repo":"reduxjs/react-redux","slug":"this-function-is-not-supported-in-react-server-com","errorCode":null,"errorMessage":"This function is not supported in React Server Components. Please only use this export in a Client Component.","messagePattern":"This function is not supported in React Server Components\\. Please only use this export in a Client Component\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/index-rsc.ts","lineNumber":17,"sourceCode":"import type * as normal from './index'\nimport type * as rsc from './index-rsc'\n\n// checks to make sure we didn't forgot to replicate any exports\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst _check: typeof normal = {} as typeof rsc\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst _check2: typeof rsc = {} as typeof normal\n\n// -------------------------------------------------------------------------------------\n\nconst throwNotSupportedError = ((\n  // eslint-disable-next-line @typescript-eslint/no-unused-vars\n  ...args: any[]\n): any => {\n  throw new Error(\n    'This function is not supported in React Server Components. Please only use this export in a Client Component.',\n  )\n}) as any\n\nexport {\n  throwNotSupportedError as Provider,\n  throwNotSupportedError as batch,\n  throwNotSupportedError as connect,\n  throwNotSupportedError as legacy_connect,\n  throwNotSupportedError as createDispatchHook,\n  throwNotSupportedError as createSelectorHook,\n  throwNotSupportedError as createStoreHook,\n  throwNotSupportedError as useDispatch,\n  throwNotSupportedError as useSelector,\n  throwNotSupportedError as useStore,\n}\nexport const ReactReduxContext = {} as any\nexport { default as shallowEqual } from './utils/shallowEqual'","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/reduxjs/react-redux/blob/16f1a91eb2cc3817bf63753e8c90e528a9f0580c/src/index-rsc.ts#L1-L35","documentation":"react-redux ships an RSC-only entry (index-rsc.ts) in which every export (Provider, connect, hooks, batch, etc.) is replaced by throwNotSupportedError. Calling any of them while running on the server in a React Server Components environment throws this error, because these APIs rely on React context and client-side rendering.","triggerScenarios":"Importing from 'react-redux' inside a file marked with 'use server' or a server component in Next.js App Router, or misconfigured bundler conditions resolving to the react-server export condition when the module is used in shared/server code.","commonSituations":"Calling useSelector or useDispatch in a Next.js server component, importing a connect-based HOC module at the top of a server-only file, or a bundler/exports misconfiguration applying the react-server condition to client code.","solutions":["Mark the component using react-redux APIs with 'use client' at the top of the file","Move store reads/writes into a client component child; pass data from the server component as props","If the file must be shared, split react-redux usage into a separate 'use client' module","Check tsconfig/bundler 'customConditions'/'exports' so the react-server condition isn't applied to client bundles"],"exampleFix":"// before (server component)\nexport default function Page() {\n  const items = useSelector(selectItems) // throws\n  return <List items={items} />\n}\n// after\n'use client'\nexport default function ClientList() {\n  const items = useSelector(selectItems)\n  return <List items={items} />\n}","handlingStrategy":"validation","validationCode":"// client-boundary.ts\n'use client'\nexport { Provider, useSelector, useDispatch } from 'react-redux'\n// server components must import only from the boundary file, never 'react-redux' directly","typeGuard":"function isClientComponent(source: string): boolean {\n  return source.startsWith(\"'use client'\") || source.startsWith('\"use client\"');\n}","tryCatchPattern":"try {\n  return useSelector(selectData)\n} catch (e) {\n  if (e.message.includes('React Server Components')) {\n    throw new Error('Move this component to a \\'use client\\' file')\n  }\n  throw e\n}","preventionTips":["Add 'use client' to every file that imports react-redux","Keep data fetching in server components and pass results as props to client components","Audit bundle conditions so the react-server export condition only applies to RSC builds"],"tags":["react-server-components","rsc","client-component","react-redux","ssr"],"backgroundTag":"rsc-unsupported-api","analyzedSha":"16f1a91eb2cc3817bf63753e8c90e528a9f0580c","analyzedAt":"2026-08-31T22:28:37.628Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}