Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sign Out Button build errors #138

Closed
kmankan opened this issue Nov 16, 2024 · 1 comment
Closed

Sign Out Button build errors #138

kmankan opened this issue Nov 16, 2024 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@kmankan
Copy link

kmankan commented Nov 16, 2024

When I include the SignOut button in my nextJS build I am unable to proceed with my build due to build errors. Am I missing something or doing something wrong here? Or some config I need to change? Seems like the issue is in the way the Impersonation function tries to use 'use server' in-line which nextJS compiler doesn't like.

Update: Actually it stops me from using withAuth() as well.

Build Error

Failed to compile.

./node_modules/@workos-inc/authkit-nextjs/dist/esm/impersonation.js
Error:   x It is not allowed to define inline "use server" annotated Server Actions in Client Components.
  | To use Server Actions in a Client Component, you can either export them from a separate file with "use server" at the top, or pass them down through props from a Server Component.

47 |                 lineHeight: '1.4',
 48 |             } },
 49 |             React.createElement("form", { action: async () => {
 50 |                     'use server';
    :                     ^^^^^^^^^^^^
 51 |                     await signOut();
 52 |                 }, style: {
 53 |                     display: 'flex',

Sign Out Function

import { signOut } from "@workos-inc/authkit-nextjs";

export async function handleSignOut() {
  await signOut();
}

Use In Component

            <form action={handleSignOut}>
              <Button type="submit" variant="ghost" size={large ? "3" : "2"}>
                Sign Out
              </Button>
            </form>
@PaulAsjes PaulAsjes added the duplicate This issue or pull request already exists label Nov 18, 2024
@PaulAsjes
Copy link
Contributor

Closing this as it's a duplicate of #80

Hoping to have a fix out soon, will keep you updated in the other issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Development

No branches or pull requests

2 participants