UNPKG

@tanosugi/better-auth-utils

Version:

Better Auth Utils

74 lines (62 loc) 1.86 kB
# @tanosugi/better-auth-utils ## Installation ```bash npm install @tanosugi/better-auth-utils # or yarn add @tanosugi/better-auth-utils # or bun add @tanosugi/better-auth-utils ``` ## Usage You can obtain localized ui words dictionary for better-auth-ui by following codes. ```ts // src/app/auth/view.tsx const { data: uiLocaleDict, isLoading: isUiLocaleDictLoading } = useUILocaleDict(locale); if (!uiLocaleDict || isUiLocaleDictLoading) { return <div>Loading...</div> ); <AuthCard pathname={pathname} redirectTo={redirectTo} localization={{ ...uiLocaleDict, passwordInvalid: "Password must contain at least one number, one uppercase letter, one lowercase letter, and one special character", }} /> ``` To obtain localized dictionary for better-auth-ui, please set up following ```ts // src/app/api/locale-ue/route.ts import { createUiLocaleHandler } from "@tanosugi/better-auth-utils/api"; export const GET = createUiLocaleHandler(); ``` You can enable localization for error codes from api in better auth by adding the localization plugin. ```ts // src/lib/auth.ts export const auth = betterAuth({ plugins: [localization()] }); ``` ## Supported Languages | Language | Language Code | |------------|--------------| | Arabic | ar | | Chinese | zh-CN | | Czech | cs | | Dutch | nl | | English | en | | French | fr | | German | de | | Hindi | hi | | Indonesian | id | | Italian | it | | Japanese | ja | | Korean | ko | | Polish | pl | | Portuguese | pt | | Russian | ru | | Spanish | es | | Thai | th | | Turkish | tr | | Ukrainian | uk | | Vietnamese | vi | ---