{"record":{"id":"6ae7640d97180286","repo":"vercel/next.js","slug":"attempted-to-call-the-default-export-of-server-mo","errorCode":null,"errorMessage":"Attempted to call the default export of {server_module_path} from the server, but it's 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 the default export of (.+?) from the server, but it's 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":null,"httpStatus":null,"severity":"error","filePath":"crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_module.rs","lineNumber":102,"sourceCode":"            if !exports.dynamic_exports.is_empty() {\n                // TODO: throw? warn?\n            }\n\n            writedoc!(\n                code,\n                r#\"\n                    // This file is generated by next-core EcmascriptClientReferenceModule.\n                    import {{ registerClientReference }} from \"react-server-dom-turbopack/server\";\n                \"#,\n            )?;\n\n            for export_name in exports.exports.keys() {\n                if export_name == \"default\" {\n                    writedoc!(\n                        code,\n                        r#\"\n                            export default registerClientReference(\n                                function() {{ throw new Error({call_err}); }},\n                                {server_module_path},\n                                \"default\",\n                            );\n                        \"#,\n                        call_err = StringifyJs(&format!(\n                            \"Attempted to call the default export of {server_module_path} from \\\n                             the server, but it's on the client. It's not possible to invoke a \\\n                             client function from the server, it can only be rendered as a \\\n                             Component or passed to props of a Client Component.\"\n                        )),\n                        server_module_path = StringifyJs(server_module_path),\n                    )?;\n                } else {\n                    writedoc!(\n                        code,\n                        r#\"\n                            export const {export_name} = registerClientReference(\n                                function() {{ throw new Error({call_err}); }},","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_module.rs#L84-L120","documentation":"Generated by Turbopack's EcmascriptClientReferenceModule proxy: when a file marked with 'use client' is imported on the server, the framework registers its default export as a `registerClientReference` whose body throws this message if *called*. React Server Components may pass client components as elements/props, but invoking a client function directly from server code is impossible because client code never runs on the server. The proxy throws at the call site to surface the boundary violation.","triggerScenarios":"In a Server Component (or server-only module), calling the default export of a 'use client' module as a function: `const result = ClientDefault()` instead of `<ClientDefault />` or passing `ClientDefault` as a prop. Also happens when a client component's default is a hook/util and you invoke it from server code.","commonSituations":"Forgetting the 'use client' boundary and calling a client-side helper from an RSC; passing a client module's default into server logic expecting a function return value; migrating a Pages Router shared util into App Router without splitting server/client.","solutions":["Render the client default as a component (`<ClientDefault {...props} />`) instead of calling it.","If you need its *behavior* on the server, move that logic into a server module without 'use client', or extract a shared server-safe utility.","If you need to pass it to a Client Component, pass the component reference itself (not its invocation) as a prop.","Search the server file for direct calls `(...)` on imports coming from 'use client' files and convert them to JSX or remove them."],"exampleFix":"// before (server component)\nimport ClientHelper from './client-helper' // 'use client'\nconst data = ClientHelper(arg) // throws\n\n// after — render as component or move logic server-side\nimport ClientHelper from './client-helper'\nreturn <ClientHelper arg={arg} />","handlingStrategy":"type-guard","validationCode":"// In server code, never call a client default as a function.\n// Instead, render or pass it:\nimport ClientComp from './client-comp' // 'use client'\n// ❌ ClientComp(arg)\n// ✅\nreturn <ClientComp arg={arg} />","typeGuard":"// A 'use client' boundary can be detected by reading the file header:\nfunction isClientModule(src: string): boolean {\n  return /^['\"]use client['\"]/m.test(src.slice(0, 1000))\n}","tryCatchPattern":null,"preventionTips":["Keep server-only logic in modules without 'use client'.","Render client components as JSX; pass them as props, never call them.","Review imports from 'use client' files in server components."],"tags":["rsc","react-server-components","use-client","client-reference","turbopack","server-client-boundary"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}