Giter VIP home page Giter VIP logo

refine-auth-kinde-react's Introduction

@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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.