@refine-auth/kinde-react
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

@refine-auth/kinde-react

License NPM Version NPM Downloads GitHub Repo stars Code Climate maintainability

@refine-auth/kinde-react is an auth provider for refine to integrate kinde authentication.

Installation & Usage

You can install the library using npm or yarn:

npm install @refine-auth/kinde-react
# or
yarn add @refine-auth/kinde-react

Add Provider Component

Kinde uses a React Context Provider to maintain its internal state in your application.

Import the Kinde Provider component and wrap your application in it.

import { RefineKindeProvider } from "@refine-auth/kinde-react";

<RefineKindeProvider
    clientId="KINDE_CLIENT_ID"
    domain="KINDE_DOMAIN"
    logoutUri={window.location.origin}
    redirectUri={window.location.origin}
>
    <App />
</RefineKindeProvider>

Basic Hook Usage

To use authProvider with Refine App, use Hook.

import { useAuthProvider } from "@refine-auth/kinde-react";

const App = () => {
    const { authProvider } = useAuthProvider();
  return (
    <Refine
      authProvider={authProvider}
      /* ... */
    >
      {/* ... */}
    </Refine>
  );
};
  

How to use login

Kinde is using redirection based authentication. So, instead of AuthPage, we just need to use login method.

import { useLogin } from "@refinedev/core";

const { mutate: login } = useLogin();

// ***

<Button onClick={() => login({redirectPath: "/"})}>
    Sign in
</Button>

Properties

The useAuthProvider hook returns the following properties:

  • authProvider (AuthProvider): Object with methods from AuthBinding of refine.

  • isLoading (boolean): A flag that indicates whether authentication is currently being loaded or fetched. You can use this property to conditionally render loading indicators or content.

  • token (string): Represents authentication token, to be used for API authentications.

Documentation

Made with ❤️ by Hiren F | GitHub

Dependencies (1)

Dev Dependencies (3)

Package Sidebar

Install

npm i @refine-auth/kinde-react

Weekly Downloads

126

Version

1.0.3

License

none

Unpacked Size

12.6 kB

Total Files

13

Last publish

Collaborators

  • hirenf14