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

createContext is not a function when trying to implement on Nextjs14 #229

Open
GFialho opened this issue Oct 31, 2024 · 1 comment
Open
Labels

Comments

@GFialho
Copy link

GFialho commented Oct 31, 2024

I am trying to implement AuthKitProvider on NextJs 14.2.4 but I'm having this error when adding AuthKitProvider:

TypeError: (0 , react__WEBPACK_IMPORTED_MODULE_2__.createContext) is not a function

This is my code:

import "@farcaster/auth-kit/styles.css";

import { AuthKitProvider } from "@farcaster/auth-kit";

const config = {
  relay: "https://relay.farcaster.xyz",
  rpcUrl: "https://mainnet.optimism.io",
  siweUri: "http://example.com/login",
  domain: "example.com",
};

export default async function FarcastProvider({
  children,
}: {
  children: React.ReactNode;
}) {
  return <AuthKitProvider config={config}>{children}</AuthKitProvider>;
}

And I am adding it on may layout.tsx

      <RootStyleRegistry>
          <Theme>
            <ContextProvider cookies={cookies}>
              <ClientProvider session={session}>
                <FarcastProvider>
                  <SolWalletProvider>
                    <EvmWalletProvider>
                      <ApolloWrapper>
                        <WalletManagerProvider>
                          <SolWalletManagerProvider>
                            {children}

                            <IntercomComponent />
                          </SolWalletManagerProvider>
                        </WalletManagerProvider>
                      </ApolloWrapper>
                    </EvmWalletProvider>
                  </SolWalletProvider>
                  <Toaster />
                </FarcastProvider>
              </ClientProvider>
            </ContextProvider>
          </Theme>
        </RootStyleRegistry>
        ```
@evanryuu
Copy link

Hi GFialho, have you tried add 'use client' on top of your FarcastProvider.tsx file?

If the question still exists, check the app/api/auth/[...nextauth]/route.ts file. See if the createAppClient, viemConnector are imported from @farcaster/auth-kit. If they are, import them from @farcaster/auth-client.

I hope these could resolve the problem for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants