naystack - v1.5.10
    Preparing search index...

    Function AuthWrapper

    • Provider that fetches the current access token from your auth endpoint and exposes it via TokenContext. Wrap your app (or the part that needs auth) so that useToken(), useLogin(), useSignUp(), useLogout() work. On mount it GETs NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT with credentials; the response's accessToken is stored and provided to children.

      Must be placed above ApolloWrapper in the component tree (since ApolloWrapper needs the token).

      Parameters

      • children: { children: ReactNode }

        React children (e.g. your app or a layout).

      Returns Element

      TokenContext.Provider wrapping children.

      // app/layout.tsx
      import { AuthWrapper } from "naystack/auth/client";
      import { ApolloWrapper } from "naystack/graphql/client";

      export default function RootLayout({ children }: { children: React.ReactNode }) {
      return (
      <html lang="en">
      <body>
      <AuthWrapper>
      <ApolloWrapper>{children}</ApolloWrapper>
      </AuthWrapper>
      </body>
      </html>
      );
      }