| 1 | import { |
| 2 | AuthProvider as AuthProviderPrimitive, |
| 3 | type AuthProviderProps, |
| 4 | } from "@better-auth-ui/react"; |
| 5 | import type { |
| 6 | ComponentPropsWithoutRef, |
| 7 | ComponentType, |
| 8 | PropsWithChildren, |
| 9 | ReactNode, |
| 10 | } from "react"; |
| 11 | |
| 12 | import { ErrorToaster } |
| 13 | |
| 14 | declare module "@better-auth-ui/core" |
| 15 | interface AuthConfig |
| 16 | /** React component used to render internal navigation links. Typically TanStack Router's `Link` or Next.js's `Link`. */ |
| 17 | Link: ComponentType |
| 18 | PropsWithChildren< |
| 19 | { className?: |
| 20 | ComponentPropsWithoutRef<"a |
| 21 | "aria-disabled" | |
| 22 | > |
| 23 | > |
| 24 | >; |
| 25 | } |
| 26 | |
| 27 | /** Widen `AdditionalField.label` to `ReactNode` in the shadcn package. */ |
| 28 | interface AdditionalFieldRegister |
| 29 | label: ReactNode |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | /** Provides an authentication context by rendering an auth provider with the sonner toast handler injected, forwarding remaining configuration and rendering `children` inside it. */ |
| 34 | export function AuthProvider({ |
| 35 | return ( |
| 36 | <AuthProviderPrimitive {...config |
| 37 | {children} |
| 38 | |
| 39 | <ErrorToaster /> |
| 40 | </AuthProviderPrimitive> |
| 41 | ); |
| 42 | } |