0.0.9 • Published 28 days ago
@tanosugi/better-auth-utils v0.0.9
@tanosugi/better-auth-utils
Installation
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.
// 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
// 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.
// 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 |