Skip to content
← Back to activity

Immutable solution version

Error: "Only async functions are allowed to be exported in a 'use server' file"

Version 1Sign in to save

Complete solution

[CodeConnoisseur (accepted answer)] I had a similar issue in next 14 where I was using an index.ts file to centralize my exports of server actions.

[CodeConnoisseur (accepted answer)] I had a similar issue in next 14 where I was using an index.ts file to centralize my exports of server actions. The issue was that I needed to remove the 'use server' from the index.ts file itself. WRONG: `` 'use server' /** * Simplify and centralize server action exports */ export { signIn } from "./signIn"; export { signOut } from "./signOut"; export { createComment } from "./createComment"; export { createPost } from "./createPost"; export { createTopic } from "./createTopic"; `` CORRECT: Remove use server from top of file.

Context: Stack Overflow #76957592 (accepted answer, 20 votes, 3 answers): I am trying to use layout.tsx in the app directory of Next.js 13 to have a nav layout that is present on all the pages. I managed to make it so that when the user logs out/signs in, the navbar changes, but the issue is that I have to refresh the page (F5) to see the change on the navbar. I think this issue is related to the cache, and that's why I am trying to use export const dynamic = 'force-dynamic'. I also added the client component to a server component because I thought that would be the issue, but it didn't solve the problem. I wanted to use export const dynamic = 'force-dynamic' to de

Evidence

Source: Stack Overflow #76957592 (accepted answer, 20 votes, 3 answers): I am trying to use layout.tsx in the app directory of Next.js 13 to have a nav layout that is present on all the pages. I managed to make it so that when the user logs out/signs in, the navbar changes, but the issue is that I have to refresh the page (F5) to see the change on the navbar. I think this issue is related to the cache, and that's why I am trying to use export const dynamic = 'force-dynamic'. I also added the client component to a server component because I thought that would be the issue, but it didn't solve the problem. I wanted to use export const dynamic = 'force-dynamic' to de

Verified resolution: [CodeConnoisseur (accepted answer)] I had a similar issue in next 14 where I was using an index.ts file to centralize my exports of server actions. The issue was that I needed to remove the 'use server' from the index.ts file itself. WRONG: `` 'use server' /** * Simplify and centralize server action exports */ export { signIn } from "./signIn"; export { signOut } from "./signOut"; export { createComment } from "./createComment"; export { createPost } from "./createPost"; export { createTopic } from "./createTopic"; `` CORRECT: Remove use server from top of file.

Source URL: https://stackoverflow.com/questions/76957592

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_Mi3nKxTJ8BS1OvqvnKIDSg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Error: &quot;Only async functions are allowed to be exported in a &#39;use server&#39; file&quot; <span>— Vectle</span></a>