{"record":{"id":"b1b0e648d5fa61f4","repo":"facebook/react","slug":"attempted-to-call-string-name-from-the-serve","errorCode":null,"errorMessage":"Attempted to call ${String(name)}() from the server but ${String(name)} is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.","messagePattern":"Attempted to call (.+?)\\(\\) from the server but (.+?) is on the client\\. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-server-dom-turbopack/src/ReactFlightTurbopackReferences.js","lineNumber":300,"sourceCode":"        return then;\n      } else {\n        // Since typeof .then === 'function' is a feature test we'd continue recursing\n        // indefinitely if we return a function. Instead, we return an object reference\n        // if we check further.\n        return undefined;\n      }\n  }\n  if (typeof name === 'symbol') {\n    throw new Error(\n      'Cannot read Symbol exports. Only named exports are supported on a client module ' +\n        'imported on the server.',\n    );\n  }\n  let cachedReference = target[name];\n  if (!cachedReference) {\n    const reference: ClientReference<any> = registerClientReferenceImpl(\n      function () {\n        throw new Error(\n          // eslint-disable-next-line react-internal/safe-string-coercion\n          `Attempted to call ${String(name)}() from the server but ${String(name)} is on the client. ` +\n            `It's not possible to invoke a client function from the server, it can ` +\n            `only be rendered as a Component or passed to props of a Client Component.`,\n        );\n      } as any,\n      target.$$id + '#' + name,\n      target.$$async,\n    );\n    Object.defineProperty(reference as any, 'name', {value: name});\n    cachedReference = target[name] = new Proxy(reference, deepProxyHandlers);\n  }\n  return cachedReference;\n}\n\nconst proxyHandlers = {\n  get: function (\n    target: Function,","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-server-dom-turbopack/src/ReactFlightTurbopackReferences.js#L282-L318","documentation":"Each named export of a 'use client' module becomes a registered client reference whose call body throws when invoked: client code cannot run on the server, so the reference may only be rendered as a component or forwarded as a prop to another client component.","triggerScenarios":"`ClientModule.handler(args)` — directly or via `await ClientModule.handler()` — inside a server component or any server-side module.","commonSituations":"Calling a client-side helper from RSC; sharing validation/format functions across the boundary; invoking a callback instead of passing it to a client component.","solutions":["Pass the function reference as a prop to a client component and invoke it there","If the server needs the result, implement the logic in a plain server module or a 'use server' action","Re-check which side of the boundary the utility module is meant to run on"],"exampleFix":"// before (server component)\nimport {validate} from './form-client';\nconst ok = validate(input); // Error: cannot invoke client fn from server\n\n// after (server component)\nimport {validate} from './validation'; // plain server module\nconst ok = validate(input);\n// or pass through: <Form validator={validateClient} />","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"const CLIENT_REFERENCE = Symbol.for('react.client.reference');\nfunction isClientReference(value) {\n  return value != null && (typeof value === 'object' || typeof value === 'function') && value.$$typeof === CLIENT_REFERENCE;\n}\nfunction assertCallableOnServer(fn) {\n  if (isClientReference(fn)) {\n    throw new Error('Pass this function to a client component; do not call it on the server');\n  }\n  return fn;\n}","tryCatchPattern":null,"preventionTips":["Pass client functions as props; never invoke them in server code","Duplicate small pure helpers into a shared server module when the server needs results","Use 'use server' for logic the server must execute"],"tags":["react-server-components","turbopack","client-references","use-client","function-call"],"backgroundTag":"rsc-client-server-boundary","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}