0.0.0-alpha.0 • Published 18 days ago

@bastaai/ory-kratos-react-hooks v0.0.0-alpha.0

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
18 days ago

Ory Kratos React Hooks

Collection of convenient hooks for working with Ory Kratos, identity and user management system.

Hooks

  • useFlow: This hook allows you to easily manage authentication flows in your React applications.
  • useSession: Use this hook to access and manage user sessions with Ory Kratos.

Examples

useFlow

  • flowType: login | registration | recovery | settings | verification
  • render keys: input | a | img | text | script. Components are uncontrolled and submitted via form.
const { html, return_to } = useFlow({
  flowType: 'login',
  options: {
    render: {
      input: ({ meta, props }) => {
        if (props.type === 'submit') {
          return <Button {...props}>{meta.label?.text}</Button>;
        }

        return <input {...props} />;
      },
      a: () => {...},
      img: () => {...},
      text: () => {...},
      script: () => {...},
    },
  },
})