@userfront/react
Version:
Transform your React application with Userfront authentication
96 lines (92 loc) • 3.67 kB
text/typescript
import * as react_jsx_runtime from 'react/jsx-runtime';
import * as react from 'react';
import { ComponentProps, ReactNode } from 'react';
import Userfront, { SignupForm as SignupForm$1, LoginForm as LoginForm$1, PasswordResetForm as PasswordResetForm$1, LogoutButton as LogoutButton$1 } from '@userfront/toolkit/react';
/**
* Signup Form
*/
type SignupFormProps = ComponentProps<typeof SignupForm$1>;
declare const SignupForm: react.ForwardRefExoticComponent<{
tenantId?: string | undefined;
flow?: object | undefined;
compact?: boolean | undefined;
theme?: object | undefined;
} & react.RefAttributes<never>>;
/**
* Login Form
*/
type LoginFormProps = ComponentProps<typeof LoginForm$1>;
declare const LoginForm: react.ForwardRefExoticComponent<{
tenantId?: string | undefined;
flow?: object | undefined;
compact?: boolean | undefined;
theme?: object | undefined;
} & react.RefAttributes<never>>;
/**
* Password Reset Form
*/
type PasswordResetFormProps = ComponentProps<typeof PasswordResetForm$1>;
declare const PasswordResetForm: react.ForwardRefExoticComponent<{
tenantId?: string | undefined;
theme?: object | undefined;
} & react.RefAttributes<never>>;
/**
* Password Reset Form
*/
type LogoutButtonProps = ComponentProps<typeof LogoutButton$1>;
declare const LogoutButton: react.ForwardRefExoticComponent<{
disabled?: boolean | undefined;
theme?: object | undefined;
} & react.RefAttributes<never>>;
type UserfrontInstance = Required<typeof Userfront>;
interface UserfrontProviderProps {
children?: ReactNode;
/**
* Tenant ID from Userfront (**required**)
*/
tenantId: string;
/**
* Loading skeleton component
*/
skeleton?: ReactNode | null;
/**
* Redirect URL for unauthenticated visitors that need to login
* @default "/login"
*/
loginUrl?: string;
/**
* Redirect URL after login, set to `false` to disable.
* When `undefined`, use the path configured to the workspace
* [paths & routing settings](https://userfront.com/dashboard/paths)
*/
loginRedirect?: string | boolean;
/**
* Redirect URL after signup, set to `false` to disable.
* When `undefined`, use the path configured to the workspace
* [paths & routing settings](https://userfront.com/dashboard/paths)
*/
signupRedirect?: string | boolean;
/**
* Redirect URL after logout, set to `false` to disable.
* When `undefined`, use the path configured to the workspace
* [paths & routing settings](https://userfront.com/dashboard/paths)
*/
logoutRedirect?: string | boolean;
/**
* Require authentication - unauthorized will redirect to `loginUrl` and authorized users will be redirected to `loginRedirect`
* @default true
*/
requireAuth?: boolean;
/**
* Base URL for the Userfront API
* If not set defaults to "https://api.userfront.com/v0/"
*/
baseUrl?: string;
}
type UserfrontContextType = UserfrontInstance & Omit<UserfrontProviderProps, "children"> & {
isAuthenticated: boolean;
isLoading: boolean;
};
declare function UserfrontProvider({ baseUrl, children, loginRedirect, loginUrl, logoutRedirect, requireAuth, signupRedirect, skeleton, tenantId, }: UserfrontProviderProps): react_jsx_runtime.JSX.Element;
declare function useUserfront(): UserfrontContextType;
export { LoginForm, type LoginFormProps, LogoutButton, type LogoutButtonProps, PasswordResetForm, type PasswordResetFormProps, SignupForm, type SignupFormProps, type UserfrontContextType, type UserfrontInstance, UserfrontProvider, type UserfrontProviderProps, useUserfront };