Registry / web-framework / better-auth-ui-svelte

better-auth-ui-svelte

JSON →
library0.12.4jsnpmunverified

better-auth-ui-svelte provides pre-built, customizable authentication UI components designed specifically for integration with the Better Auth backend in Svelte 5 applications. Currently at version 0.12.4, this library is in active early stage development, cautioning users that it is not yet battle-tested in production environments and issues may arise before a v1.0 stable release. The package aims for a rapid iteration cycle, with minor and patch releases occurring frequently as seen in its recent history (multiple patch and minor releases within months). A key differentiator is its full feature parity with the original Better Auth UI React library, leveraging Svelte 5 runes and modern practices, while also introducing Svelte-specific utilities like path helpers. It is styled with Tailwind CSS v4 and built upon shadcn-svelte components, offering extensive customization options out-of-the-box. The library supports Zod 4 for form validation and is localization-ready, but users should be aware that this Svelte port may diverge from the React version's API and features over time.

npm install better-auth-ui-svelte
INSTALL
IMPORT
SIG · BETTER-AUTH-UI-SVE
B
better-auth-ui-svelte
web-frameworkjavascriptv0.12.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AuthLayout
import { AuthLayout } from 'better-auth-ui-svelte';
const AuthLayout = require('better-auth-ui-svelte').AuthLayout;
The library primarily uses named exports. Direct CommonJS `require` for specific components is generally not recommended in modern SvelteKit projects which favor ESM.
UserButton
import { UserButton } from 'better-auth-ui-svelte';
import UserButton from 'better-auth-ui-svelte/UserButton.svelte';
Components are re-exported from the main entry point; importing directly from '.svelte' files is not the intended public API.
nlLocalization
import { nlLocalization } from 'better-auth-ui-svelte';
import { nlLocalization } from 'better-auth-ui-svelte/localization';
Localization objects are named exports from the root, not separate subpaths, since v0.8.0.

This quickstart demonstrates setting up the Better Auth client, integrating Tailwind CSS, and using fundamental UI components like `AuthLayout`, `UserButton`, and `ChangeEmailCard` in a SvelteKit project.

import { SvelteKitAuth } from 'better-auth/client'; import { AuthLayout, UserButton, ChangeEmailCard } from 'better-auth-ui-svelte'; // In src/lib/auth.ts (or similar) export const auth = new SvelteKitAuth({ apiEndpoint: '/api/auth' }); // In src/routes/+layout.svelte <script lang="ts"> import { onMount } from 'svelte'; import '../app.css'; // Your global CSS with Tailwind imports import { auth } from '$lib/auth'; onMount(() => { // Initialize auth client if needed, or ensure stores are reactive }); </script> <AuthLayout> <UserButton /> </AuthLayout> <!-- In src/routes/settings/email/+page.svelte --> <script lang="ts"> import { auth } from '$lib/auth'; </script> <ChangeEmailCard auth={auth} />
Debug
Known issues
gotchaThis library is in early stage development and has not been battle-tested in production environments. Issues may arise before v1.0 stable. Use at your own risk.
fix
Thoroughly test components in your specific application context and be prepared to address potential bugs or API changes. Monitor the GitHub repository for updates and contribute feedback.
affects: >=0.1.0
breakingFor TailwindCSS v4, the CSS import mechanism changed from content configuration to a direct `@import` statement in your global CSS. Older content configuration for v3 is deprecated.
fix
For TailwindCSS v4, add `@import 'better-auth-ui-svelte/css';` to your global CSS file (e.g., `app.css`). Remove the `content: ['./node_modules/better-auth-ui-svelte/dist/**/*.{js,svelte}']` entry from your `tailwind.config.js` if upgrading.
affects: >=0.1.0
gotchaThe Svelte port may evolve independently and diverge from the original React library's API and features over time, prioritizing the needs of the Svelte ecosystem and maintainer's projects.
fix
Consult the Svelte port's specific documentation and changelog, rather than relying solely on the React version's documentation, to stay informed about potential differences.
affects: >=0.1.0
gotchaChanges in Svelte 5's reactivity model, specifically the use of `$derived` and `$effect` runes, can lead to infinite reactive loops or delayed data loading if not handled carefully, particularly with form fields or data fetching.
fix
Ensure that `form.setFieldValue()` calls or similar state updates within `$effect` blocks are wrapped in `untrack()` to prevent re-triggering the effect unnecessarily. Verify that hooks are not called inside `$derived` computations, which can cause unexpected behavior.
affects: >=0.7.0
breakingThe `UserButton` component's structure was enhanced with a `menuItems` snippet prop, allowing callers to inject custom `DropdownMenu` items.
fix
If you had custom logic for extending the `UserButton`'s dropdown, refactor to use the new `menuItems` snippet prop. For example: `<UserButton>{#snippet menuItems()}...your custom items...{/snippet}</UserButton>`.
affects: >=0.9.0
Errors
Common errors & fixes
Failed to resolve import "better-auth-ui-svelte/css" from "<your-css-file>"
Incorrect path or missing CSS file for TailwindCSS v4 import.
fix
Ensure your `better-auth-ui-svelte` package is correctly installed and that the `@import 'better-auth-ui-svelte/css';` statement is in a CSS file processed by TailwindCSS.
Error: Hydration completed but contains mismatches.
Client-side rendering output does not match server-side rendering output, often due to dynamic content or environmental differences during SSR.
fix
Check for components that render differently based on client-side state or environment variables. Ensure consistent configuration between SSR and CSR, and consider using `onMount` for client-only rendering logic for non-critical elements.
Error: hooks called inside $derived
Svelte 5 runes are misused, specifically calling reactive hooks (like those for data fetching or effects) within a `$derived` block.
fix
Move any side-effecting or hook-based logic out of `$derived` computations. `$derived` should only compute a value based on other reactive states, not perform actions. Use `$effect` for side effects.
Infinite reactive loop detected in Svelte 5 form or effect.
A state update within an `$effect` or form handler is causing the effect or form to re-evaluate and update the state again, leading to an endless cycle.
fix
Wrap state-setting calls within `$effect` blocks (e.g., `form.setFieldValue()`) in `untrack(() => { ... })` to prevent the update from re-triggering the effect itself. Carefully manage dependencies and side effects in Svelte 5 runes.
Upgrade
Version history
0.12.4latest on npm
Audit
Dependencies
svelterequiredCore Svelte framework, specifically Svelte 5.
@sveltejs/kitoptionalUsed for SvelteKit integration and server/client-side path utilities.
better-authrequiredThe core authentication client library that these UI components integrate with.
@better-auth/passkeyoptionalUsed for passkey authentication features.
bits-uirequiredUnderlying headless UI component library for accessibility and composability.
@lucide/svelterequiredIcon library used within the components.
tailwindcssrequiredStyling framework used for all components (v4 recommended).
zodrequiredSchema validation library for forms.
@noble/hashesoptionalCryptographic hashing library, likely for internal authentication processes.
d3-scaleoptionalData visualization utility, potentially for dashboards or analytics components.
d3-shapeoptionalData visualization utility, potentially for dashboards or analytics components.
layerchartoptionalCharting library, likely for analytics or user activity displays.
Agent activity
23 hits · last 30 days
node
20
Amazon
1
OpenAI (training)
1
Resources
better-auth-ui-svelte — npm install better-auth-ui-svelte · libregistry