--- title: UI Components Reference subtitle: Quick reference for Neon Auth UI components enableTableOfContents: true updatedOn: '2025-12-18T12:00:58.022Z' --- Quick reference for Neon Auth UI components from `@neondatabase/neon-js`. These components are built with [Better Auth UI](https://better-auth-ui.com/) and work with Neon Auth. ## Installation ```bash npm install @neondatabase/neon-js ``` ## Provider Setup Wrap your app with `NeonAuthUIProvider` to enable the UI components. The provider accepts configuration props that control which features are available. ### Basic Setup ```tsx import { NeonAuthUIProvider } from '@neondatabase/neon-js/auth/react'; import '@neondatabase/neon-js/ui/css'; import { authClient } from './auth'; function App() { return ( {/* Your app components */} ); } ``` ### Common Props | Prop | Type | Description | Example | | ---------------------------- | ------------------------ | --------------------------------------------------------- | ---------------------------------------------- | | `authClient` | `NeonAuthPublicApi` | **Required.** Your Neon Auth client instance | `authClient={authClient}` | | `social.providers` | `SocialProvider[]` | Array of OAuth providers to enable (e.g., Google, GitHub) | `social={{ providers: ['google', 'github'] }}` | | `navigate` | `(href: string) => void` | Navigation function for React Router | `navigate={navigate}` | | `Link` | `ComponentType` | Custom Link component for routing | `Link={RouterLink}` | | `localization` | `AuthLocalization` | Customize text labels throughout the UI | See example below | | `avatar` | `AvatarOptions` | Avatar upload and display configuration | `avatar={{ size: 256, extension: 'webp' }}` | | `additionalFields` | `AdditionalFields` | Custom fields for sign-up and account settings | See example below | | `credentials.forgotPassword` | `boolean` | Enable forgot password flow | `credentials={{ forgotPassword: true }}` | ### Enable OAuth Providers To enable Google sign-in (or other OAuth providers), add the `social` prop to the provider: ```tsx import { NeonAuthUIProvider } from '@neondatabase/neon-js/auth/react'; import { authClient } from './auth'; function App() { return ( {/* Your app */} ); } ``` **Note:** Google OAuth works with shared credentials for development. GitHub OAuth requires custom credentials. The `social.providers` prop controls which provider buttons are displayed in the UI. For production, configure your own OAuth credentials in the Neon Console (Settings → Auth). See the [OAuth setup guide](/docs/auth/guides/setup-oauth) for details. ### React Router Integration If using React Router, pass the `navigate` function and a custom `Link` component: ```tsx import { NeonAuthUIProvider } from '@neondatabase/neon-js/auth/react'; import { useNavigate, Link as RouterLink } from 'react-router-dom'; import { authClient } from './auth'; function App() { const navigate = useNavigate(); return ( {/* Your app */} ); } ``` ### Customization Examples **Custom localization:** ```tsx ``` **Custom sign-up fields:** ```tsx ``` For complete prop documentation, see the TypeScript types exported from `@neondatabase/neon-js/auth/react`. ## Core Components ### Authentication Components | Component | Purpose | Key Props | Docs | | ------------ | ------------------------------------------------- | ---------- | ------------------------------------------------------------ | | `` | All-in-one auth UI with sign-in and sign-up forms | `pathname` | [auth-view](https://better-auth-ui.com/components/auth-view) | **Form Components:** ``, ``, ``, ``, and `` are also available. `` includes sign-in and sign-up functionality with a "create account" link to switch between forms. Use the form components separately if you need more control over layout. **OAuth Provider Buttons:** OAuth provider buttons (Google, GitHub, etc.) appear automatically in `` when configured via the `social.providers` prop. OAuth buttons do not appear in standalone `` or `` components. ### User Management Components | Component | Purpose | Key Props | Docs | | -------------------- | ------------------------------------- | ---------------------- | -------------------------------------------------------------------------------- | | `` | User menu dropdown with avatar | - | [user-button](https://better-auth-ui.com/components/user-button) | | `` | Profile picture with Gravatar support | `user`, `size` | [user-avatar](https://better-auth-ui.com/components/user-avatar) | | `` | Conditional rendering when signed in | `children`, `fallback` | [signed-in](https://better-auth-ui.com/components/signed-in) | | `` | Conditional rendering when signed out | `children`, `fallback` | [signed-out](https://better-auth-ui.com/components/signed-out) | | `` | Redirect helper to sign-in page | `redirectTo` | [redirect-to-sign-in](https://better-auth-ui.com/components/redirect-to-sign-in) | | `` | Redirect helper to sign-up page | `redirectTo` | [redirect-to-sign-up](https://better-auth-ui.com/components/redirect-to-sign-up) | ## Styling Choose the import method based on your project setup: ### Without Tailwind CSS If your project doesn't use Tailwind CSS, import the pre-built CSS bundle: ```typescript // In your root layout or app entry point import '@neondatabase/neon-js/ui/css'; ``` This includes all necessary styles (~47KB minified) with no additional configuration required. ### With Tailwind CSS v4 If your project already uses Tailwind CSS v4, import the Tailwind-ready CSS to avoid duplicate styles: ```css /* In your main CSS file (e.g., globals.css) */ @import 'tailwindcss'; @import '@neondatabase/neon-js/ui/tailwind'; ``` This imports only the theme variables. Your Tailwind build generates the utility classes. Never import both paths. This causes duplicate styles. For customization options, see **Styling** details within each Better Auth UI component docs page. Example: [Auth View styling](https://better-auth-ui.com/components/auth-view#styling). ## Example Usage ### Basic Auth Flow ```tsx import { AuthView } from '@neondatabase/neon-js/auth/react/ui'; import '@neondatabase/neon-js/ui/css'; function App() { return ; } ``` ### User Menu ```tsx import { UserButton } from '@neondatabase/neon-js/auth/react/ui'; import { authClient } from './auth'; function Header() { return (
); } ``` ### Protected Route ```tsx import { SignedIn, SignedOut, RedirectToSignIn } from '@neondatabase/neon-js/auth/react/ui'; function Dashboard() { return ( <>

Dashboard

); } ``` ## Next Steps - See [React with Neon Auth UI](/docs/auth/quick-start/react-router-components) for a complete example - Check the [JavaScript SDK (Auth & Data API)](/docs/reference/javascript-sdk) for programmatic auth methods