---
title: Welcome to Clerk Docs
description: Add complete user management to your application in minutes.
template: wide
lastUpdated: 2025-11-21T22:00:50.000Z
sdkScoped: "false"
canonical: /docs
sourceFile: /docs/index.mdx
---
Find all the guides and resources you need to develop with Clerk.
* [Quickstarts & Tutorials](/docs/getting-started/quickstart/overview)
* Explore our end-to-end tutorials and getting started guides for different application stacks using Clerk.
* {}
***
* [UI Components](/docs/reference/components/overview)
* Clerk's prebuilt UI components give you a beautiful, fully-functional user management experience in minutes.
* {}
***
* [SDK Reference](/docs/reference/overview)
* Dig into our SDK reference documentation. We have everything you need to get started setting up authentication with Clerk.
* {}
***
* [Security](/docs/guides/secure/restricting-access)
* Account security is the top concern of every feature we build. This documentation lists some of the many protections included with Clerk.
* {}
* [Quickstarts & Tutorials](/docs/getting-started/quickstart/overview)
* Explore our end-to-end tutorials and getting started guides for different application stacks using Clerk.
* {}
***
* [Views](/docs/reference/views/overview)
* Clerk's prebuilt Views give you a beautiful, fully-functional user management experience in minutes.
* {}
***
* [SDK Reference](/docs/reference/overview)
* Dig into our SDK reference documentation. We have everything you need to get started setting up authentication with Clerk.
* {}
***
* [Security](/docs/guides/secure/restricting-access)
* Account security is the top concern of every feature we build. This documentation lists some of the many protections included with Clerk.
* {}
## Explore by frontend framework
{/* TODO: Keep aligned with /reference/overview */}
* [Next.js](/docs/nextjs/getting-started/quickstart)
* Easily add secure, beautiful, and fast authentication to Next.js with Clerk.
*
***
* [React](/docs/react/getting-started/quickstart)
* Get started installing and initializing Clerk in a new React + Vite app.
*
***
* [Astro](/docs/astro/getting-started/quickstart)
* Easily add secure and SSR-friendly authentication to your Astro application with Clerk.
*
***
* [Chrome Extension](/docs/chrome-extension/getting-started/quickstart)
* Use the Chrome Extension SDK to authenticate users in your Chrome extension.
*
***
* [Expo](/docs/expo/getting-started/quickstart)
* Use Clerk with Expo to authenticate users in your React Native application.
*
***
* [Android](/docs/android/getting-started/quickstart)
* Use the Clerk Android SDK to authenticate users in your native Android applications.
*
***
* [iOS](/docs/ios/getting-started/quickstart)
* Use the Clerk iOS SDK to authenticate users in your native Apple applications.
*
***
* [JavaScript](/docs/js-frontend/getting-started/quickstart)
* The Clerk JavaScript SDK gives you access to prebuilt components and helpers to make user authentication easier.
*
***
* [Nuxt](/docs/nuxt/getting-started/quickstart)
* Easily add secure, beautiful, and fast authentication to Nuxt with Clerk.
*
***
* [React Router](/docs/react-router/getting-started/quickstart)
* Easily add secure, edge- and SSR-friendly authentication to React Router with Clerk.
*
***
* [Remix](/docs/remix/getting-started/quickstart)
* Easily add secure, edge- and SSR-friendly authentication to Remix with Clerk.
*
***
* [TanStack React Start (beta)](/docs/tanstack-react-start/getting-started/quickstart)
* Easily add secure and SSR-friendly authentication to your TanStack React Start application with Clerk.
*
***
* [Vue](/docs/vue/getting-started/quickstart)
* Get started installing and initializing Clerk in a new Vue + Vite app.
*
## Explore by backend framework
{/* TODO: Keep aligned with /reference/overview */}
* [JS Backend SDK](/docs/js-backend/getting-started/quickstart)
* The JavaScript Backend SDK exposes our Backend API resources and low-level authentication utilities for JavaScript environments.
*
***
* [C#](https://github.com/clerk/clerk-sdk-csharp/blob/main/README.md)
* The Clerk C# SDK is a wrapper around our Backend API to make it easier to integrate Clerk into your backend.
*
***
* [Express](/docs/expressjs/getting-started/quickstart)
* Quickly add authentication and user management to your Express application.
*
***
* [Go](/docs/go/getting-started/quickstart)
* The Clerk Go SDK is a wrapper around the Backend API written in Golang to make it easier to integrate Clerk into your backend.
*
***
* [Fastify](/docs/fastify/getting-started/quickstart)
* Build secure authentication and user management flows for your Fastify server.
*
***
* [Python](https://github.com/clerk/clerk-sdk-python/blob/main/README.md)
* The Clerk Python SDK is a wrapper around the Backend API written in Python to make it easier to integrate Clerk into your backend.
*
***
* [Ruby on Rails](/docs/ruby/getting-started/quickstart)
* Integrate authentication and user management into your Ruby application.
*
## Explore by feature
* [Authentication](/docs/guides/configure/auth-strategies/sign-up-sign-in-options)
* Clerk supports multiple authentication strategies so you can implement the strategy that makes sense for your users.
* {}
***
* [User management](/docs/guides/users/managing)
* Complete user management. Add sign up, sign in, and profile management to your application in minutes.
* {}
***
* [Database integrations](/docs/guides/development/integrations/overview)
* Enable Clerk-managed users to authenticate and interact directly with your database with Clerk's integrations.
* {}
***
* [Customization](/docs/guides/customizing-clerk/appearance-prop/overview)
* Clerk's components can be customized to match the look and feel of your application.
* {}
***
* [Organizations](/docs/guides/organizations/overview)
* Organizations are shared accounts, useful for project and team leaders. Members with elevated privileges can manage member access to the Organization's data and resources.
* {}
***
* [SDKs](/docs/reference/overview)
* Clerk's SDKs allow you to call the Clerk server API without having to implement the calls yourself.
* {}
## Learn the concepts
* [What is Clerk authentication?](/docs/guides/configure/auth-strategies/sign-up-sign-in-options)
* Clerk offers multiple authentication strategies to identify legitimate users of your application, and to allow them to make authenticated requests to your backend.
* {{ dark: '/docs/images/home/what-is-clerk-dark.png' }}
***
* [What is the "User" object?](/docs/guides/users/managing)
* The User object contains all account information that describes a user of your app in Clerk. Users can authenticate and manage their accounts, update their personal and contact info, or set up security features for their accounts.
* {{ dark: '/docs/images/home/user-object-dark.png' }}
***
* [How do Organizations work?](/docs/guides/organizations/overview)
* Organizations allow members to collaborate across shared resources. Each member of an Organization needs to have a user account in your application. All Organization members have access to most of the Organization resources, but some members can take advantage of administrative features.
* {{ dark: '/docs/images/home/organizations-dark.png' }}
* [Join our Discord](https://clerk.com/discord "Join Discord")
* Join our official Discord server to chat with us directly and become a part of the Clerk community.
* {}
***
* [Need help?](/support "Get help")
* Contact us through Discord, Twitter, or email to receive answers to your questions and learn more about Clerk.
* {}
---
title: Pin a Clerk SDK
description: Learn how to pin a Clerk SDK to a specific version.
lastUpdated: 2025-11-19T22:57:21.000Z
sdkScoped: "false"
canonical: /docs/pinning
sourceFile: /docs/pinning.mdx
---
Dependency pinning allows you to specify exact package versions in your project, ensuring consistent behavior across different environments and preventing unexpected updates from breaking your application.
Typically, package managers use semantic versioning ([SemVer](https://semver.org/)) ranges when installing packages. When you install your Clerk SDK, you'll typically see an entry like `"@clerk/nextjs": "^1.1.0"` in your package.json. The caret (^) symbol means "any version that is compatible with 1.1.0" - this includes patch releases (1.1.1, 1.1.2) and minor releases (1.2.0, 1.3.0) but excludes major releases (2.0.0).
Another range operator is the tilde (~) symbol for more restrictive versioning. An entry like `"@clerk/nextjs": "~1.1.0"` means "any version from 1.1.0 up to (but not including) 1.2.0" - this only allows patch updates within the same minor version.
When you **pin a dependency**, you specify the exact version **without any range operators**. For example, `"@clerk/nextjs": "1.1.0"` means "use exactly version 1.1.0, no other version." This approach gives you complete control over which version your application uses.
With Clerk, we recommend pinning your Clerk SDK in **both** of these ways:
1. Pin your Clerk SDK in your `package.json` file to a specific version (no range operators).
```json {{ filename: 'package.json', prettier: false }}
"@clerk/nextjs": "1.1.0"
```
2. Set the `clerkJsVersion` property when you initialize the Clerk integration. For most SDKs, this is done in the `` component. For SDKs like Astro or Nuxt, this is done in the configuration file.
```tsx {{ prettier: false }}
```
---
title: Maintenance Mode
description: Learn about Clerk's Maintenance Mode.
lastUpdated: 2025-11-19T22:57:21.000Z
sdkScoped: "false"
canonical: /docs/maintenance-mode
sourceFile: /docs/maintenance-mode.mdx
---
> \[!IMPORTANT]
> Maintenance mode will be deprecated in 2025 as we upgrade our infrastructure.
Once or twice per year, Clerk undergoes maintenance on its infrastructure and enters **Maintenance Mode**. During this time, users who are already signed in will not be signed out, and will continue to have access to your app. However, new sign-ups, sign-ins and user mutations will return an error. **Maintenance Mode** is a special operational state designed to minimize disruption for signed-in users during critical database upgrades or outages.
## Production instances
Mutation methods (`POST`, `PATCH`, `PUT`, `DELETE`) will be rejected with a `SystemUnderMaintenance` error. This includes all new sign-ups and sign-ins.
Active sessions, and session refresh requests **are not** affected. This applies to `GET` requests as well as session refresh requests ([`/touch`](/docs/reference/frontend-api/tag/sessions/post/v1/client/sessions/\{session_id}/touch) and [`/tokens`](/docs/reference/frontend-api/tag/sessions/post/v1/client/sessions/\{session_id}/tokens) endpoints). Users who are already signed in will not be signed out and will continue to have access to your app. However, any mutations to their user or org data will return the same `SystemUnderMaintenance` error.
### API errors
All mutations from both the Frontend API and the Backend API will return the following `SystemUnderMaintenance` error.
```json
// 503 StatusServiceUnavailable
{
"shortMessage": "System under maintenance",
"longMessage": "We are currently undergoing maintenance and only essential operations are permitted. We will be back shortly.",
"code": "maintenance_mode"
}
```
### UI components
During **Maintenance Mode**, Clerk's UI components will display the following error for sign-ins, sign-ups, and all mutations to user and org data.

## Development instances
For development instances, all requests will return a `SystemUnderMaintenance ` error, and the instance will be completely unavailable.
---
title: JavaScript Backend SDK
description: The JavaScript Backend SDK exposes Clerk's Backend API resources
and low-level authentication utilities for JavaScript environments.
sdk: nextjs, react, js-frontend, chrome-extension, expo, android, ios,
expressjs, fastify, react-router, remix, tanstack-react-start, go, astro,
nuxt, vue, ruby, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/getting-started/quickstart
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,react,js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
notAvailableSdks: ""
activeSdk: js-backend
sourceFile: /docs/getting-started/quickstart.js-backend.mdx
---
[Clerk's JavaScript Backend SDK](/docs/reference/backend/overview) exposes the [Backend API](/docs/reference/backend-api){{ target: '_blank' }} resources and low-level authentication utilities **for JavaScript environments**.
For example, if you wanted to get a list of all users in your application, instead of creating a fetch to [`https://api.clerk.com/v1/users`](/docs/reference/backend-api/tag/users/get/users){{ target: '_blank' }} endpoint, you can use the [`users.getUserList()`](/docs/reference/backend/user/get-user-list) method provided by the JS Backend SDK.
## Installation
If you are using the JS Backend SDK on its own, you can install it using the following command:
```npm {{ filename: 'terminal' }}
npm install @clerk/backend
```
Clerk SDKs expose an instance of the JS Backend SDK for use in server environments, so there is no need to install it separately.
## Usage
All resource operations are mounted as sub-APIs on the `clerkClient` object. For example, if you would like to get a list of all of your application's users, you can use the `getUserList()` method on the `users` sub-API. You can find the full list of available sub-APIs and their methods in the sidenav.
To access a resource, you must first instantiate a `clerkClient` instance.
To instantiate a `clerkClient` instance, you must call `createClerkClient()` and pass in options.
> \[!NOTE]
> This example uses `process.env` to import environment variables. You may need to use an alternative method, such as `import.meta.env`, to set environment variables for your project.
```ts
import { createClerkClient } from '@clerk/backend'
const clerkClient = createClerkClient({ secretKey: process.env.CLERK_SECRET_KEY })
```
### Instantiate a default `clerkClient` instance
You can use the default instance of `clerkClient` provided by whichever SDK you are using, and skip the need to pass configuration options, unless you are using Remix. For Remix, see the following section.
To use the default `clerkClient` instance, set your `CLERK_SECRET_KEY` [environment variable](/docs/guides/development/clerk-environment-variables#clerk-publishable-and-secret-keys) and then import the `clerkClient` instance from the SDK as shown in the following example:
```jsx
import { clerkClient } from '@clerk/nextjs/server'
```
```js
import { clerkClient } from '@clerk/astro/server'
```
```js
import { clerkClient } from '@clerk/express'
```
```jsx
import { clerkClient } from '@clerk/fastify'
```
```js
import { clerkClient } from '@clerk/nuxt/server'
```
If you are using React Router, see the following section for how to instantiate `clerkClient`.
If you are using Remix, see the following section for how to instantiate `clerkClient`.
```js
import { clerkClient } from '@clerk/tanstack-react-start/server'
```
### Instantiate a custom `clerkClient` instance
If you would like to customize the behavior of the JS Backend SDK, you can instantiate a `clerkClient` instance yourself by calling `createClerkClient()` and passing in options.
```jsx
import { createClerkClient } from '@clerk/nextjs/server'
const clerkClient = createClerkClient({ secretKey: process.env.CLERK_SECRET_KEY })
const client = await clerkClient()
const userList = await client.users.getUserList()
```
If you are using Astro, you must pass the [endpoint context](https://docs.astro.build/en/reference/api-reference/#endpoint-context) when invoking the `clerkClient` function.
```jsx
import { clerkClient } from '@clerk/astro/server'
export async function GET(context) {
const { isAuthenticated, userId, redirectToSignIn } = context.locals.auth()
if (!isAuthenticated) {
return redirectToSignIn()
}
const user = await clerkClient(context).users.getUser(userId)
return new Response(JSON.stringify({ user }))
}
```
```js
import { createClerkClient } from '@clerk/express'
const clerkClient = createClerkClient({ secretKey: process.env.CLERK_SECRET_KEY })
const userList = await clerkClient.users.getUserList()
```
```jsx
import { createClerkClient } from '@clerk/fastify'
const clerkClient = createClerkClient({ secretKey: process.env.CLERK_SECRET_KEY })
const userList = await clerkClient.users.getUserList()
```
```tsx {{ filename: 'server/api/users/index.ts' }}
import { createClerkClient } from '@clerk/nuxt/server'
export default defineEventHandler(async () => {
const config = useRuntimeConfig()
const clerkClient = createClerkClient({ secretKey: config.clerk.secretKey })
const userList = await clerkClient.users.getUserList()
return { userList }
})
```
```tsx {{ filename: 'app/routes/example.tsx' }}
import { createClerkClient } from '@clerk/react-router/api.server'
export async function loader(args: Route.LoaderArgs) {
const userList = await createClerkClient({
secretKey: process.env.CLERK_SECRET_KEY,
}).users.getUserList()
return {
userList: JSON.stringify(userList),
}
}
export default function Users({ loaderData }: Route.ComponentProps) {
return (
List of users
{JSON.stringify(loaderData, null, 2)}
)
}
```
If you are using Remix, you must instantiate `clerkClient` by calling the `createClerkClient()` function and passing in options.
```jsx
import { createClerkClient } from '@clerk/remix/api.server'
```
Use the following tabs to see examples of how to use the JS Backend SDK in Remix Loader and Action functions.
```tsx {{ filename: 'routes/profile.tsx' }}
import { LoaderFunction, redirect } from '@remix-run/node'
import { getAuth } from '@clerk/remix/ssr.server'
import { createClerkClient } from '@clerk/remix/api.server'
export const loader: LoaderFunction = async (args) => {
// Use getAuth to retrieve user data
const { isAuthenticated, userId } = await getAuth(args)
// Protect the route by checking if the user is signed in
if (!isAuthenticated) {
return redirect('/sign-in?redirect_url=' + args.request.url)
}
// Initialize clerkClient and perform the action,
// which in this case is to get the user
const user = await createClerkClient({ secretKey: process.env.CLERK_SECRET_KEY }).users.getUser(
userId,
)
// Return the user
return { serialisedUser: JSON.stringify(user) }
}
```
```tsx {{ filename: 'routes/profile.tsx' }}
import { ActionFunction, redirect } from '@remix-run/node'
import { getAuth } from '@clerk/remix/ssr.server'
import { createClerkClient } from '@clerk/remix/api.server'
export const action: ActionFunction = async (args) => {
// Use getAuth to retrieve user data
const { isAuthenticated, userId } = await getAuth(args)
// Protect the route by checking if the user is signed in
if (!isAuthenticated) {
return redirect('/sign-in?redirect_url=' + args.request.url)
}
// Initialize clerkClient and perform the action,
// which in this case is to get the user
const user = await createClerkClient({ secretKey: process.env.CLERK_SECRET_KEY }).users.getUser(
userId,
)
// Return the user
return { serialisedUser: JSON.stringify(user) }
}
```
```tsx {{ filename: 'app/routes/api/example.tsx' }}
import { clerkClient } from '@clerk/tanstack-react-start/server'
import { json } from '@tanstack/react-start'
import { createServerFileRoute } from '@tanstack/react-start/server'
export const ServerRoute = createServerFileRoute().methods({
GET: async ({ request, params }) => {
const userList = await clerkClient({
secretKey: import.meta.env.CLERK_SECRET_KEY,
}).users.getUserList()
return json({ userList })
},
})
```
## Error handling
JS Backend SDK functions throw errors (`ClerkAPIResponseError`) when something goes wrong. You'll need to catch them in a `try/catch` block and handle them gracefully. For example:
```ts {{ filename: 'example.ts' }}
try {
const res = await someBackendApiCall()
} catch (error) {
// Error handling
}
```
## `createClerkClient({ options })`
The `createClerkClient()` function requires an `options` object. It is recommended to set these options as [environment variables](/docs/guides/development/clerk-environment-variables#api-and-sdk-configuration) where possible, and then pass them to the function. For example, you can set the `secretKey` option using the `CLERK_SECRET_KEY` environment variable, and then pass it to the function like this: `createClerkClient({ secretKey: process.env.CLERK_SECRET_KEY })`.
The following options are available:
* `secretKey` (required)
* `string`
The Clerk Secret Key from the [**API keys**](https://dashboard.clerk.com/~/api-keys) page in the Clerk Dashboard.
***
* `jwtKey?`
* `string`
The **JWKS Public Key** from the [**API keys**](https://dashboard.clerk.com/~/api-keys) in the Clerk Dashboard. For more information, refer to [Manual JWT verification](/docs/guides/sessions/manual-jwt-verification).
***
* `publishableKey?`
* `string`
The Clerk Publishable Key from the [**API keys**](https://dashboard.clerk.com/~/api-keys) page in the Clerk Dashboard.
***
* `domain?`
* `string`
The domain of a [satellite application](/docs/guides/dashboard/dns-domains/satellite-domains) in a multi-domain setup.
***
* `isSatellite?`
* `boolean`
Whether the instance is a satellite domain in a multi-domain setup. Defaults to `false`.
***
* `proxyUrl?`
* `string`
The proxy URL from a multi-domain setup.
***
* `sdkMetadata?`
* `{ name: string, version: string }`
Metadata about the SDK.
***
* `telemetry?`
* `{ disabled: boolean, debug: boolean }`
[Telemetry](/docs/guides/how-clerk-works/security/clerk-telemetry) configuration.
***
* `userAgent?`
* `string`
The User-Agent request header passed to the Clerk API.
***
* `apiUrl?`
* `string`
The [Clerk Backend API](/docs/reference/backend-api){{ target: '_blank' }} endpoint. Defaults to `'https://api.clerk.com'`.
***
* `apiVersion?`
* `string`
The version passed to the Clerk API. Defaults to `'v1'`.
***
* `audience?`
* `string | string[]`
A string or list of [audiences](https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.3).
***
* `taskUrls?`
* `Record`
The URL paths users are redirected to after sign-up or sign-in when specific session tasks need to be completed. For example, `{ 'choose-organization': '/onboarding/choose-organization' }` redirects users to `/onboarding/choose-organization` after sign-up if they need to choose an Organization.
## Get the `userId` and other properties
The [`Auth`](/docs/reference/backend/types/auth-object) object contains important information like the current user's session ID, user ID, and Organization ID.
{/* How to access the `Auth` object */}
The `Auth` object is available on the `request` object in server contexts. Some frameworks provide a helper that returns the `Auth` object. See the following table for more information.
| Framework | How to access the `Auth` object |
| - | - |
| Next.js App Router | auth() |
| Next.js Pages Router | getAuth() |
| Astro | locals.auth() |
| Express | req.auth |
| React Router | getAuth() |
| Remix | getAuth() |
| Tanstack React Start | auth() |
| Other | `request.auth` |
The following example demonstrates how to retrieve the authenticated user's ID using `request.auth` when you're not using a specific framework helper. It also shows how to use the JS Backend SDK's [`getUser()`](/docs/reference/backend/user/get-user) method to get the [Backend `User` object](/docs/reference/backend/types/backend-user).
```js
import { createClerkClient } from '@clerk/backend'
const clerkClient = createClerkClient({ secretKey: process.env.CLERK_SECRET_KEY })
async function getUserId(request) {
// Use the `request.auth` object to access `isAuthenticated` and the user's ID
const { isAuthenticated, userId } = request.auth
// If user isn't authenticated, return null
if (!isAuthenticated) {
return null
}
// Use the JS Backend SDK's `getUser()` method to get the Backend User object
const user = await clerkClient.users.getUser(userId)
// Return the Backend User object
return user
}
```
The following examples demonstrate how to retrieve the authenticated user's ID using framework-specific auth helpers and how to use the JS Backend SDK's [`getUser()`](/docs/reference/backend/user/get-user) method to get the [Backend `User` object](/docs/reference/backend/types/backend-user).
**If your SDK isn't listed, you can use the comments in the example to help you adapt it to your SDK.**
{/* TODO: The following Tabs example is duplicated in the guides/how-clerk-works/session-tokens.mdx file. It cannot be a partial to be reused across both files because this example includes a partial and partials cannot include partials. Also, the text in each of these tabs is removed in the other file as its not relevant to that file's example. So keep these two Tabs examples in sync please. */}
For Next.js, the `Auth` object is accessed using the `auth()` helper in App Router apps and the `getAuth()` function in Pages Router apps. Learn more about using these helpers.
Use the following tabs to see examples of how to use these helpers to access the user's ID in your App Router or Pages Router app.
```tsx {{ filename: 'app/api/example/route.ts' }}
import { auth, clerkClient } from '@clerk/nextjs/server'
export async function GET() {
// The `Auth` object gives you access to properties like `isAuthenticated` and `userId`
// Accessing the `Auth` object differs depending on the SDK you're using
// https://clerk.com/docs/reference/backend/types/auth-object#how-to-access-the-auth-object
const { isAuthenticated, userId } = await auth()
// Protect the route by checking if the user is signed in
if (!isAuthenticated) {
return new NextResponse('Unauthorized', { status: 401 })
}
const client = await clerkClient()
// Initialize the JS Backend SDK
// This varies depending on the SDK you're using
// https://clerk.com/docs/js-backend/getting-started/quickstart
const user = await client.users.getUser(userId)
// Return the Backend User object
return NextResponse.json({ user: user }, { status: 200 })
}
```
```tsx {{ filename: 'pages/api/auth.ts' }}
import { getAuth, clerkClient } from '@clerk/nextjs/server'
import type { NextApiRequest, NextApiResponse } from 'next'
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
// Use `getAuth()` to access `isAuthenticated` and the user's ID
const { isAuthenticated, userId } = getAuth(req)
// Protect the route by checking if the user is signed in
if (!isAuthenticated) {
return res.status(401).json({ error: 'Unauthorized' })
}
// Initialize the JS Backend SDK
const client = await clerkClient()
// Get the user's full Backend User object
const user = await client.users.getUser(userId)
return res.status(200).json({ user })
}
```
For Astro, the `Auth` object is accessed using the `locals.auth()` function. Learn more about using `locals.auth()`.
```tsx {{ filename: 'src/api/example.ts' }}
import { clerkClient } from '@clerk/astro/server'
import type { APIRoute } from 'astro'
export const GET: APIRoute = async (context) => {
// The `Auth` object gives you access to properties like `isAuthenticated` and `userId`
// Accessing the `Auth` object differs depending on the SDK you're using
// https://clerk.com/docs/reference/backend/types/auth-object#how-to-access-the-auth-object
const { isAuthenticated, userId } = context.locals.auth()
// Protect the route by checking if the user is signed in
if (!isAuthenticated) {
return new Response('Unauthorized', { status: 401 })
}
// Initialize the JS Backend SDK
// This varies depending on the SDK you're using
// https://clerk.com/docs/js-backend/getting-started/quickstart
const user = await clerkClient(context).users.getUser(userId)
// Return the Backend User object
return new Response(JSON.stringify({ user }))
}
```
For Express, the `Auth` object is accessed using the `getAuth()` function. Learn more about using `getAuth()`.
```js {{ filename: 'index.js' }}
import { createClerkClient, getAuth } from '@clerk/express'
import express from 'express'
const app = express()
const clerkClient = createClerkClient({ secretKey: process.env.CLERK_SECRET_KEY })
app.get('/user', async (req, res) => {
// The `Auth` object gives you access to properties like `isAuthenticated` and `userId`
// Accessing the `Auth` object differs depending on the SDK you're using
// https://clerk.com/docs/reference/backend/types/auth-object#how-to-access-the-auth-object
const { isAuthenticated, userId } = getAuth(req)
// Protect the route by checking if the user is signed in
if (!isAuthenticated) {
res.status(401).json({ error: 'User not authenticated' })
}
// Initialize the JS Backend SDK
// This varies depending on the SDK you're using
// https://clerk.com/docs/js-backend/getting-started/quickstart
// Use the `getUser()` method to get the Backend User object
const user = await clerkClient.users.getUser(userId)
// Return the Backend User object
res.json(user)
})
```
For React Router, the `Auth` object is accessed using the `getAuth()` function. Learn more about using `getAuth()`.
```tsx {{ filename: 'app/routes/profile.tsx' }}
import { redirect } from 'react-router'
import { clerkClient, getAuth } from '@clerk/react-router/server'
import type { Route } from './+types/profile'
export async function loader(args: Route.LoaderArgs) {
// The `Auth` object gives you access to properties like `isAuthenticated` and `userId`
// Accessing the `Auth` object differs depending on the SDK you're using
// https://clerk.com/docs/reference/backend/types/auth-object#how-to-access-the-auth-object
const { isAuthenticated, userId } = await getAuth(args)
// Protect the route by checking if the user is signed in
if (!isAuthenticated) {
return redirect('/sign-in?redirect_url=' + args.request.url)
}
// Use the JS Backend SDK's `getUser()` method to get the Backend User object
const user = await clerkClient(args).users.getUser(userId)
// Return the Backend User object
return {
user: JSON.stringify(user),
}
}
```
For Tanstack React Start, the `Auth` object is accessed using the `auth()` function. Learn more about using `auth()`.
```tsx {{ filename: 'app/routes/api/example.tsx' }}
import { json } from '@tanstack/react-start'
import { createFileRoute } from '@tanstack/react-router'
import { auth, clerkClient } from '@clerk/tanstack-react-start/server'
export const ServerRoute = createFileRoute('/api/example')({
server: {
handlers: {
GET: async () => {
// The `Auth` object gives you access to properties like `isAuthenticated` and `userId`
// Accessing the `Auth` object differs depending on the SDK you're using
// https://clerk.com/docs/reference/backend/types/auth-object#how-to-access-the-auth-object
const { isAuthenticated, userId } = await auth()
// Protect the route by checking if the user is signed in
if (!isAuthenticated) {
return json({ error: 'Unauthorized' }, { status: 401 })
}
// Initialize the JS Backend SDK
// This varies depending on the SDK you're using
// https://clerk.com/docs/js-backend/getting-started/quickstart
// Use the `getUser()` method to get the Backend User object
const user = await clerkClient().users.getUser(userId)
// Return the Backend User object
return json({ user })
},
},
},
})
```
---
title: Clerk Billing for B2B SaaS
description: Clerk Billing is a feature that allows you to create and manage
Plans and Features for your application.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/billing/for-b2b
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: js-backend
sourceFile: /docs/guides/billing/for-b2b.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing for B2B SaaS allows you to create Plans and manage Subscriptions **for companies or organizations** in your application. If you'd like to charge individual users, see Billing for B2C SaaS. You can also combine both B2C and B2B Billing in the same application.
## Enable Billing
To enable Billing for your application, navigate to the [**Billing Settings**](https://dashboard.clerk.com/~/billing/settings) page in the Clerk Dashboard. This page will guide you through enabling Billing for your application.
Clerk Billing costs the same as using Stripe Billing directly, just 0.7% per transaction, plus transaction fees which are paid directly to Stripe. Clerk Billing is **not** the same as Stripe Billing. Plans and pricing are managed directly through the Clerk Dashboard and won't sync with your existing Stripe products or plans. Clerk uses Stripe **only** for payment processing, so you don't need to set up Stripe Billing.
### Payment gateway
Once you have enabled Billing, you will see the following **Payment gateway** options for collecting payments via Stripe:
* **Clerk development gateway**: A shared **test** Stripe account used for development instances. This allows developers to test and build Billing flows **in development** without needing to create and configure a Stripe account.
* **Stripe account**: Use your own Stripe account for production. **A Stripe account created for a development instance cannot be used for production**. You will need to create a separate Stripe account for your production environment.
## Create a Plan
Subscription Plans are what your customers subscribe to. There is no limit to the number of Plans you can create. If your Clerk instance has existing [Custom Permissions](/docs/guides/organizations/roles-and-permissions), the corresponding Features from those Permissions will automatically be added to the free Plan for Orgs. This ensures that Organization members get the same set of Custom Permissions when Billing is enabled, because all Organizations start on the free Plan.
To create a Plan, navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard. Here, you can create, edit, and delete Plans. To setup B2B Billing, select the **Plans for Organizations** tab and select **Add Plan**. When creating a Plan, you can also create [Features](/docs/guides/secure/features) for the Plan; see the next section for more information.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's an Organization Plan, it can appear in the `` component. When creating or editing a Plan, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Add Features to a Plan
[Features](/docs/guides/secure/features) make it easy to give entitlements to your Plans. You can add any number of Features to a Plan.
You can add a Feature to a Plan when you are creating a Plan. To add it after a Plan is created:
1. Navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard.
2. Select the Plan you'd like to add a Feature to.
3. In the **Features** section, select **Add Feature**.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's an Organization Plan, it can appear in the `` component. When adding a Feature to a Plan, it will also automatically appear in the corresponding Plan. When creating or editing a Feature, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Create a pricing page
You can create a pricing page by using the \ component. This component displays a table of Plans and Features that customers can subscribe to. **It's recommended to create a dedicated page**, as shown in the following example.
> \[!NOTE]
> To see an example of how to create a pricing table page, please select one of the frontend SDKs on the sidebar.
## Control access with Features, Plans, and Permissions
You can use Clerk's Features, Plans, and Permissions to gate access to content using authorization checksAuthorization checks are checks you perform in your code to determine the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions or access certain content. Learn more about [authorization checks](/docs/guides/secure/authorization-checks).. There are a few ways to do this, but the recommended approach is to either use the [`has()`](/docs/reference/backend/types/auth-object#has) method or the \ component.
The `has()` method is available for any JavaScript-based framework, while `` is a component, and therefore, is only available for React-based frameworks.
> \[!IMPORTANT]
> Permission-based authorization checks link with Feature-based authorization checks. This means that if you are checking a Custom Permission, it will only work if the Feature part of the Permission key (`org::`) **is a Feature included in the Organization's active Plan**. For example, say you want to check if an Organization member has the Custom Permission `org:teams:manage`, where `teams` is the Feature. Before performing the authorization check, you need to ensure that the user's Organization is subscribed to a Plan that has the `teams` Feature. If the user's Organization is not subscribed to a Plan that has the `teams` Feature, the authorization check will always return `false`, *even if the user has the Custom Permission*.
### Example: Using `has()`
Use the `has()` method to test if the Organization has access to a **Plan**:
```jsx
const hasPremiumAccess = has({ plan: 'gold' })
```
Or a **Feature**:
```jsx
const hasPremiumAccess = has({ feature: 'widgets' })
```
The [`has()`](/docs/reference/backend/types/auth-object#has) method is a server-side helper that checks if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan) and returns a boolean value. `has()` is available on the [`auth` object](/docs/reference/backend/types/auth-object), which you will access differently [depending on the framework you are using](/docs/reference/backend/types/auth-object#how-to-access-the-auth-object).
> \[!TIP]
> Why aren't Custom Permissions appearing in the session token (JWT) or in API responses (including the result of the `has()` check)?
>
> ***
>
> Custom Permissions will only appear in the session token (JWT) and in API responses (including the result of the `has()` check) if the Feature part of the Permission key (`org::`) **is a Feature included in the Organization's active Plan**. If the Feature is not part of the Plan, the `has()` check for Permissions using that Feature will return `false`, and those Permissions will not be represented in the session token.
>
> For example, say you want to check if an Organization member has the Custom Permission `org:teams:manage`, where `teams` is the Feature. The user's Organization must be subscribed to a Plan that has the `teams` Feature for authorization checks to work. If the user's Organization is not subscribed to a Plan that has the `teams` Feature, the authorization check will always return `false`, *even if the user has the Custom Permission*.
The following example demonstrates how to use `has()` to check if an Organization has a Plan.
```ts {{ filename: 'src/routes/bronze-content.ts' }}
import { createClerkClient } from '@clerk/backend'
const clerkClient = createClerkClient({
publishableKey: process.env.CLERK_PUBLISHABLE_KEY,
secretKey: process.env.CLERK_SECRET_KEY,
})
const domain =
process.env.NODE_ENV === 'production' ? 'https://example.com' : 'http://localhost:3000'
export async function GET(request: Request) {
const authenticatedRequest = await clerkClient.authenticateRequest(request, {
authorizedParties: [domain],
})
const user = authenticatedRequest.toAuth()
if (user === null || user.userId === null) {
return new Response('Unauthorized', { status: 401 })
}
const hasBronzePlan = user.has({ plan: 'bronze' })
if (!hasBronzePlan) {
return new Response('For Bronze subscribers only')
}
return new Response('Only subscribers to the Bronze plan can access this content.')
}
```
The following example demonstrates how to use `has()` to check if an Organization has a Feature.
```ts {{ filename: 'src/routes/premium-content.ts' }}
import { createClerkClient } from '@clerk/backend'
const clerkClient = createClerkClient({
publishableKey: process.env.CLERK_PUBLISHABLE_KEY,
secretKey: process.env.CLERK_SECRET_KEY,
})
const domain =
process.env.NODE_ENV === 'production' ? 'https://example.com' : 'http://localhost:3000'
export async function GET(request: Request) {
const authenticatedRequest = await clerkClient.authenticateRequest(request, {
authorizedParties: [domain],
})
const user = authenticatedRequest.toAuth()
if (user === null || user.userId === null) {
return new Response('Unauthorized', { status: 401 })
}
const hasPremiumAccess = user.has({ feature: 'premium_access' })
if (!hasPremiumAccess) {
return new Response('Only subscribers with the Premium Access feature can access this content.')
}
return new Response('Our Exclusive Content')
}
```
The following example demonstrates how to use `has()` to check if an Organization has a Permission.
```ts {{ filename: 'src/routes/manage-premium-content.ts' }}
import { createClerkClient } from '@clerk/backend'
const clerkClient = createClerkClient({
publishableKey: process.env.CLERK_PUBLISHABLE_KEY,
secretKey: process.env.CLERK_SECRET_KEY,
})
const domain =
process.env.NODE_ENV === 'production' ? 'https://example.com' : 'http://localhost:3000'
export async function GET(request: Request) {
const authenticatedRequest = await clerkClient.authenticateRequest(request, {
authorizedParties: [domain],
})
const user = authenticatedRequest.toAuth()
if (user === null || user.userId === null) {
return new Response('Unauthorized', { status: 401 })
}
const hasPremiumAccessManage = user.has({ permission: 'org:premium_access:manage' })
if (!hasPremiumAccessManage) {
return new Response(
'Only subscribers with the Premium Access Manage permission can access this content.',
)
}
return new Response('Our Exclusive Content')
}
```
### Example: Using ``
The \ component protects content or even entire routes by checking if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan). You can pass a `fallback` prop to `` that will be rendered if the Organization does not have the access control.
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Plan.
> \[!NOTE]
> To see an example of how to use the `Protect` component, please select one of the frontend SDKs on the sidebar.
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Feature.
> \[!NOTE]
> To see an example of how to use the `Protect` component, please select one of the frontend SDKs on the sidebar.
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Permission.
> \[!NOTE]
> To see an example of how to use the `Protect` component, please select one of the frontend SDKs on the sidebar.
---
title: Clerk Billing for B2C SaaS
description: Clerk Billing is a feature that allows you to create and manage
Plans and Features for your application.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/billing/for-b2c
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: js-backend
sourceFile: /docs/guides/billing/for-b2c.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing for B2C SaaS allows you to create Plans and manage Subscriptions **for individual users** in your application. If you'd like to charge companies or organizations, see Billing for B2B SaaS. You can also combine both B2C and B2B Billing in the same application.
## Enable Billing
To enable Billing for your application, navigate to the [**Billing Settings**](https://dashboard.clerk.com/~/billing/settings) page in the Clerk Dashboard. This page will guide you through enabling Billing for your application.
Clerk Billing costs the same as using Stripe Billing directly, just 0.7% per transaction, plus transaction fees which are paid directly to Stripe. Clerk Billing is **not** the same as Stripe Billing. Plans and pricing are managed directly through the Clerk Dashboard and won't sync with your existing Stripe products or plans. Clerk uses Stripe **only** for payment processing, so you don't need to set up Stripe Billing.
### Payment gateway
Once you have enabled Billing, you will see the following **Payment gateway** options for collecting payments via Stripe:
* **Clerk development gateway**: A shared **test** Stripe account used for development instances. This allows developers to test and build Billing flows **in development** without needing to create and configure a Stripe account.
* **Stripe account**: Use your own Stripe account for production. **A Stripe account created for a development instance cannot be used for production**. You will need to create a separate Stripe account for your production environment.
## Create a Plan
Subscription Plans are what your users subscribe to. There is no limit to the number of Plans you can create.
To create a Plan, navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard. Here, you can create, edit, and delete Plans. To setup B2C Billing, select the **Plans for Users** tab and select **Add Plan**. When creating a Plan, you can also create Features for the Plan; see the next section for more information.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's a user Plan, it can appear in the `` component. When creating or editing a Plan, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Add Features to a Plan
[Features](/docs/guides/secure/features) make it easy to give entitlements to your Plans. You can add any number of Features to a Plan.
You can add a Feature to a Plan when you are creating a Plan. To add it after a Plan is created:
1. Navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard.
2. Select the Plan you'd like to add a Feature to.
3. In the **Features** section, select **Add Feature**.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's a user Plan, it can appear in the `` component. When adding a Feature to a Plan, it will also automatically appear in the corresponding Plan. When creating or editing a Feature, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Create a pricing page
You can create a pricing page by using the \ component. This component displays a table of Plans and Features that users can subscribe to. **It's recommended to create a dedicated page**, as shown in the following example.
> \[!NOTE]
> To see an example of how to create a pricing table page, please select one of the frontend SDKs on the sidebar.
## Control access with Features and Plans
You can use Clerk's Features and Plans to gate access to the content. There are a few ways to do this, but the recommended approach is to either use the [`has()`](/docs/reference/backend/types/auth-object#has) method or the \ component.
The `has()` method is available for any JavaScript framework, while `` is only available for React-based frameworks.
### Example: Using `has()`
Use the `has()` method to test if the user has access to a **Plan**:
```jsx
const hasPremiumAccess = has({ plan: 'gold' })
```
Or a **Feature**:
```jsx
const hasPremiumAccess = has({ feature: 'widgets' })
```
The [`has()`](/docs/reference/backend/types/auth-object#has) method is a server-side helper that checks if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan) and returns a boolean value. `has()` is available on the [`auth` object](/docs/reference/backend/types/auth-object), which you will access differently [depending on the framework you are using](/docs/reference/backend/types/auth-object#how-to-access-the-auth-object).
The following example demonstrates how to use `has()` to check if a user has a Plan.
```ts {{ filename: 'src/routes/bronze-content.ts' }}
import { createClerkClient } from '@clerk/backend'
const clerkClient = createClerkClient({
publishableKey: process.env.CLERK_PUBLISHABLE_KEY,
secretKey: process.env.CLERK_SECRET_KEY,
})
const domain =
process.env.NODE_ENV === 'production' ? 'https://example.com' : 'http://localhost:3000'
export async function GET(request: Request) {
const authenticatedRequest = await clerkClient.authenticateRequest(request, {
authorizedParties: [domain],
})
const user = authenticatedRequest.toAuth()
if (user === null || user.userId === null) {
return new Response('Unauthorized', { status: 401 })
}
const hasBronzePlan = user.has({ plan: 'bronze' })
if (!hasBronzePlan) {
return new Response('For Bronze subscribers only')
}
return new Response('Only subscribers to the Bronze plan can access this content.')
}
```
The following example demonstrates how to use `has()` to check if a user has a Feature.
```ts {{ filename: 'src/routes/premium-content.ts' }}
import { createClerkClient } from '@clerk/backend'
const clerkClient = createClerkClient({
publishableKey: process.env.CLERK_PUBLISHABLE_KEY,
secretKey: process.env.CLERK_SECRET_KEY,
})
const domain =
process.env.NODE_ENV === 'production' ? 'https://example.com' : 'http://localhost:3000'
export async function GET(request: Request) {
const authenticatedRequest = await clerkClient.authenticateRequest(request, {
authorizedParties: [domain],
})
const user = authenticatedRequest.toAuth()
if (user === null || user.userId === null) {
return new Response('Unauthorized', { status: 401 })
}
const hasPremiumAccess = user.has({ feature: 'premium_access' })
if (!hasPremiumAccess) {
return new Response('Only subscribers with the Premium Access feature can access this content.')
}
return new Response('Our Exclusive Content')
}
```
### Example: Using ``
The \ component protects content or even entire routes by checking if the user has been granted a specific type of access control (Role, Permission, Feature, or Plan). You can pass a `fallback` prop to `` that will be rendered if the user does not have the access control.
The following example demonstrates how to use `` to protect a page by checking if the user has a Plan.
> \[!NOTE]
> To see an example of how to use the `Protect` component, please select one of the frontend SDKs on the sidebar.
The following example demonstrates how to use `` to protect a page by checking if the user has a Feature.
> \[!NOTE]
> To see an example of how to use the `Protect` component, please select one of the frontend SDKs on the sidebar.
---
title: Clerk Billing webhooks
description: Clerk Billing webhooks allow you to track subscription lifecycles
and monitor payment attempts.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/development/webhooks/billing
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: js-backend
sourceFile: /docs/guides/development/webhooks/billing.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing supports webhook events that allow you to track information like subscription lifecycles and payments.
## Subscriptions
A subscription is a top-level container unique to each user or organization. Subscription events can help you track billing changes for each of your customers.
| Event Name | Description |
| - | - |
| `subscription.created` | The top-level subscription is created. This usually happens when a user or organization is created. For existing users and organizations, a subscription will be created when Billing is enabled for the application. |
| `subscription.updated` | The top-level subscription is updated. This event is triggered when any property of the subscription has changed, except for status changes. For example, when the subscription items for the payer change. |
| `subscription.active` | The top-level subscription transitions to active from a non-active status. This happens when any subscription item is set to active, including items from the free default Plan. |
| `subscription.pastDue` | The top-level subscription contains a subscription item that has become past due. |
## Subscription items
A subscription item provides details about the relationship between the payer (user or Organization) and a Plan. A top-level subscription may contain multiple subscription items.
There can only be one `active` subscription item per payer and Plan. In addition, the subscription item for the default Plan will always have the same `id` to allow easier tracking of which users and Organizations are not paid customers.
| Event Name | Description |
| - | - |
| `subscriptionItem.updated` | The subscription item is updated. This event is triggered when a property of the subscription item has changed that does not result in a status change. For example, when a subscription item is renewed and the recurring monthly charge succeeds, the status doesn't change (remains `active`), but `period_start` and `period_end` are updated. This results in a `subscriptionItem.updated` event. |
| `subscriptionItem.active` | The subscription item is set to active. For paid Plans, this happens on successful payment. |
| `subscriptionItem.canceled` | The subscription item is canceled. The payer retains Plan features until the end of the current billing period. |
| `subscriptionItem.upcoming` | The subscription item is set as upcoming after the current billing period. This can happen in the case of a deferred Plan change from a higher-priced to lower-priced Plan. In the case a paid Plan is canceled, the subscription item for the default, free Plan will be set as `upcoming`. |
| `subscriptionItem.ended` | The subscription item has ended. |
| `subscriptionItem.abandoned` | The subscription item is abandoned. This can happen to `upcoming` subscription items if the payer subscribes to another Plan, or re-subscribes to a currently canceled Plan. |
| `subscriptionItem.incomplete` | The subscription item is incomplete. This means the payer has started a checkout for a Plan, but the payment hasn't been successfully processed yet. Once payment succeeds, the subscription item transitions to an `active` status. |
| `subscriptionItem.pastDue` | The subscription item is past due because a recurring charge has failed. |
| `subscriptionItem.freeTrialEnding` | The subscription item is a free trial and is ending soon. This event is sent three days before the trial ends. If the trial is shorter than three days, it's sent immediately. |
## Payment attempts
Payment attempts allow you to track successful and failed payments, for both checkout and recurring charges.
Payment attempt events contain a `type`, which can be either `checkout` or `recurring`. You can use these values to determine whether a payment attempt was for a checkout or a subscription item renewal's recurring charge.
| Event Name | Description |
| - | - |
| `paymentAttempt.created` | A payment attempt has been created with `pending` status. It can either succeed or fail in the future. |
| `paymentAttempt.updated` | A payment attempt has been updated to `paid` or `failed` status. |
Looking for other webhook events? To find a list of all the events Clerk supports, navigate to the [**Webhooks**](https://dashboard.clerk.com/~/webhooks) page and select the **Event Catalog** tab.
---
title: Component Reference
description: A list of Clerk's comprehensive suite of components designed to
seamlessly integrate authentication and multi-tenancy into your application.
sdk: react, nextjs, js-frontend, chrome-extension, expo, android, expressjs,
fastify, react-router, remix, tanstack-react-start, go, astro, nuxt, vue,
ruby, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/overview
lastUpdated: 2025-11-21T23:29:30.000Z
availableSdks: react,nextjs,js-frontend,chrome-extension,expo,android,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
notAvailableSdks: ios
activeSdk: js-backend
sourceFile: /docs/reference/components/overview.mdx
---
Clerk offers a comprehensive suite of components designed to seamlessly integrate authentication and multi-tenancy into your application. With Clerk components, you can easily customize the appearance of authentication components and pages, manage the entire authentication flow to suit your specific needs, and even build robust SaaS applications.
## Authentication components
* \
* \
* \
* \
* \
## User components
* \
* \
* \
## Organization components
* \
* \
* \
* \
## Billing components
* \
* \
* \
* \
## Control components
Control components manage authentication-related behaviors in your application. They handle tasks such as controlling content visibility based on user authentication status, managing loading states during authentication processes, and redirecting users to appropriate pages. Control components render at `` and `` states for assertions on the Clerk object. A common example is the \ component, which allows you to conditionally render content only when a user is authenticated.
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
## Unstyled components
* \
* \
* \
* \
## Customization guides
* [Customize components with the `appearance` prop](/docs/guides/customizing-clerk/appearance-prop/overview)
* [Localize components with the `localization` prop (experimental)](/docs/guides/customizing-clerk/localization)
* [Add pages to the `` component](/docs/guides/customizing-clerk/adding-items/user-profile)
* [Add pages to the `` component](/docs/guides/customizing-clerk/adding-items/organization-profile)
### Secured by Clerk branding
> \[!WARNING]
> This feature requires a [paid plan](/pricing){{ target: '_blank' }} for production use, but all features are free to use in development mode so that you can try out what works for you. See the [pricing](/pricing){{ target: '_blank' }} page for more information.
By default, Clerk displays a **Secured by Clerk** badge on Clerk components. You can remove this branding by following these steps:
1. In the Clerk Dashboard, navigate to your application's [**Settings**](https://dashboard.clerk.com/~/settings).
2. Under **Branding**, toggle on the **Remove "Secured by Clerk" branding** option.
* [Join our Discord](https://clerk.com/discord "Join Discord")
* Join our official Discord server to chat with us directly and become a part of the Clerk community.
* {}
***
* [Need help?](/support "Get help")
* Contact us through Discord, Twitter, or email to receive answers to your questions and learn more about Clerk.
* {}
---
title: Ruby Quickstart
description: Learn how to use Clerk to quickly and easily add secure
authentication and user management to your Ruby application.
sdk: nextjs, react, js-frontend, chrome-extension, expo, android, ios,
expressjs, fastify, react-router, remix, tanstack-react-start, go, astro,
nuxt, vue, ruby, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/getting-started/quickstart
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,react,js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
notAvailableSdks: ""
activeSdk: ruby
sourceFile: /docs/getting-started/quickstart.ruby.mdx
---
Learn how to use Clerk to quickly and easily add secure authentication and user management to your Ruby app. If you would like to use a framework, see the [reference docs](/docs/reference/ruby/overview).
## Install `clerk-sdk-ruby`
The [Clerk Ruby SDK](/docs/reference/ruby/overview) provides a range of backend utilities to simplify user authentication and management in your application.
1. Add the following code to your application's `Gemfile`.
```ruby {{ filename: 'Gemfile' }}
gem 'clerk-sdk-ruby', require: "clerk"
```
2. Run the following command to install the SDK:
```sh {{ filename: 'terminal' }}
$ bundle install
```
## Configuration
The configuration object provides a flexible way to configure the SDK. When a configuration value is not explicitly provided, it will fall back to checking the corresponding [environment variable](/docs/reference/ruby/overview#available-environment-variables). You must provide your Clerk Secret Key, which can be retrieved from the [**API keys**](https://dashboard.clerk.com/~/api-keys) page in the Clerk Dashboard.
The following example shows how to set up your configuration object:
```ruby
Clerk.configure do |c|
c.secret_key = `{{secret}}` # if omitted: ENV["CLERK_SECRET_KEY"] - API calls will fail if unset
c.logger = Logger.new(STDOUT) # if omitted, no logging
end
```
For more information, see [Faraday's documentation](https://lostisland.github.io/faraday/#/).
## Instantiate a `Clerk::SDK` instance
All available methods are listed in the [Ruby HTTP Client documentation](https://github.com/clerk/clerk-http-client-ruby/tree/main/.generated#documentation-for-api-endpoints){{ target: '_blank' }}. The Ruby HTTP Client is a generated wrapper around the [Backend API](/docs/reference/backend-api){{ target: '_blank' }} that provides a more Ruby-friendly interface.
To access available methods, you must instantiate a `Clerk::SDK` instance.
```ruby
sdk = Clerk::SDK.new
create_user_request = Clerk::SDK::CreateUserRequest.new(
first_name: "John",
last_name: "Doe",
email_address: ["john.doe@example.com"],
password: "password"
)
# Create a user
sdk.users.create(create_user_request)
# List all users and ensure the user was created
sdk.users.get_user_list
# Get the first user created in your instance
user = sdk.users.get_user_list(limit: 1).first
# Use the user's ID to lock the user
sdk.users.lock_user(user["id"])
# Then, unlock the user so they can sign in again
sdk.users.unlock_user(user["id"])
```
## Next steps
* [Ruby SDK Reference](/docs/reference/ruby/overview)
* Learn more about the Ruby SDK.
***
* [Deploy to Production](/docs/guides/development/deployment/production)
* Learn how to deploy your Clerk app to production.
---
title: Component Reference
description: A list of Clerk's comprehensive suite of components designed to
seamlessly integrate authentication and multi-tenancy into your application.
sdk: react, nextjs, js-frontend, chrome-extension, expo, android, expressjs,
fastify, react-router, remix, tanstack-react-start, go, astro, nuxt, vue,
ruby, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/overview
lastUpdated: 2025-11-21T23:29:30.000Z
availableSdks: react,nextjs,js-frontend,chrome-extension,expo,android,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
notAvailableSdks: ios
activeSdk: ruby
sourceFile: /docs/reference/components/overview.mdx
---
Clerk offers a comprehensive suite of components designed to seamlessly integrate authentication and multi-tenancy into your application. With Clerk components, you can easily customize the appearance of authentication components and pages, manage the entire authentication flow to suit your specific needs, and even build robust SaaS applications.
## Authentication components
* \
* \
* \
* \
* \
## User components
* \
* \
* \
## Organization components
* \
* \
* \
* \
## Billing components
* \
* \
* \
* \
## Control components
Control components manage authentication-related behaviors in your application. They handle tasks such as controlling content visibility based on user authentication status, managing loading states during authentication processes, and redirecting users to appropriate pages. Control components render at `` and `` states for assertions on the Clerk object. A common example is the \ component, which allows you to conditionally render content only when a user is authenticated.
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
## Unstyled components
* \
* \
* \
* \
## Customization guides
* [Customize components with the `appearance` prop](/docs/guides/customizing-clerk/appearance-prop/overview)
* [Localize components with the `localization` prop (experimental)](/docs/guides/customizing-clerk/localization)
* [Add pages to the `` component](/docs/guides/customizing-clerk/adding-items/user-profile)
* [Add pages to the `` component](/docs/guides/customizing-clerk/adding-items/organization-profile)
### Secured by Clerk branding
> \[!WARNING]
> This feature requires a [paid plan](/pricing){{ target: '_blank' }} for production use, but all features are free to use in development mode so that you can try out what works for you. See the [pricing](/pricing){{ target: '_blank' }} page for more information.
By default, Clerk displays a **Secured by Clerk** badge on Clerk components. You can remove this branding by following these steps:
1. In the Clerk Dashboard, navigate to your application's [**Settings**](https://dashboard.clerk.com/~/settings).
2. Under **Branding**, toggle on the **Remove "Secured by Clerk" branding** option.
* [Join our Discord](https://clerk.com/discord "Join Discord")
* Join our official Discord server to chat with us directly and become a part of the Clerk community.
* {}
***
* [Need help?](/support "Get help")
* Contact us through Discord, Twitter, or email to receive answers to your questions and learn more about Clerk.
* {}
---
title: Vue Quickstart
description: Add authentication and user management to your Vue app with Clerk.
sdk: nextjs, react, js-frontend, chrome-extension, expo, android, ios,
expressjs, fastify, react-router, remix, tanstack-react-start, go, astro,
nuxt, vue, ruby, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/getting-started/quickstart
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,react,js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
notAvailableSdks: ""
activeSdk: vue
sourceFile: /docs/getting-started/quickstart.vue.mdx
---
This tutorial assumes that you're using [Vue 3](https://vuejs.org/) with [TypeScript](https://www.typescriptlang.org/).
### Create a Vue app using Vite
Run the following commands to create a new Vue app using [Vite](https://vitejs.dev/guide/#scaffolding-your-first-vite-project):
```npm
npm create vite@latest clerk-vue -- --template vue-ts
cd clerk-vue
npm install
npm run dev
```
### Install `@clerk/vue`
The [Clerk Vue SDK](/docs/reference/vue/overview) gives you access to prebuilt components, composables, and helpers to make user authentication easier.
Run the following command to install the SDK:
```npm
npm install @clerk/vue
```
### Set your Clerk API keys
Add your Clerk Publishable Key to your `.env` file. This key can always be retrieved from the [**API Keys**](https://dashboard.clerk.com/~/api-keys) page in the Clerk Dashboard.
1. In the Clerk Dashboard, navigate to the [**API Keys**](https://dashboard.clerk.com/~/api-keys) page.
2. In the **Quick Copy** section, copy your Clerk Publishable Key.
3. Paste your key into your `.env` file.
The final result should resemble the following:
```env {{ filename: '.env' }}
VITE_CLERK_PUBLISHABLE_KEY={{pub_key}}
```
### Add `clerkPlugin` to your app
`clerkPlugin` provides session and user context to Clerk's components and composables. It's required to pass your Clerk Publishable Key as an option. You can add an `if` statement to check that the key is imported properly. This prevents the app from running without the Publishable Key and catches TypeScript errors.
The `clerkPlugin` accepts optional options, such as `{ signInForceRedirectUrl: '/dashboard' }`. See the [reference documentation](/docs/reference/vue/clerk-plugin) for more information.
```ts {{ filename: 'src/main.ts', mark: [4, [12, 14]] }}
import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import { clerkPlugin } from '@clerk/vue'
const PUBLISHABLE_KEY = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY
if (!PUBLISHABLE_KEY) {
throw new Error('Add your Clerk Publishable Key to the .env file')
}
const app = createApp(App)
app.use(clerkPlugin, { publishableKey: PUBLISHABLE_KEY })
app.mount('#app')
```
### Create a header with Clerk components
You can control which content signed-in and signed-out users can see with Clerk's prebuilt control components. The following example creates a header using the following components:
* \: Children of this component can only be seen while **signed in**.
* \: Children of this component can only be seen while **signed out**.
* \: Shows the signed-in user's avatar. Selecting it opens a dropdown menu with account management options.
* \: An unstyled component that links to the sign-in page or displays the sign-in modal.
```vue {{ filename: 'src/App.vue', mark: [2, [6, 13]] }}
```
### Create your first user
Run your project with the following command:
```npm
npm run dev
```
Visit your app's homepage at [`http://localhost:5173`](http://localhost:5173). Sign up to create your first user.
## More resources
Learn more about Clerk components, how to customize them, and how to use Clerk's client-side helpers using the following guides.
* [Prebuilt components](/docs/reference/components/overview)
* Learn more about Clerk's suite of components that let you quickly add authentication to your app.
***
* [Customization & localization](/docs/guides/customizing-clerk/appearance-prop/overview)
* Learn how to customize and localize Clerk components.
***
* [Client-side helpers (composables)](/docs/reference/composables/use-user)
* Learn more about Clerk's client-side helpers and how to use them.
---
title: Clerk Billing for B2B SaaS
description: Clerk Billing is a feature that allows you to create and manage
Plans and Features for your application.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/billing/for-b2b
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: vue
sourceFile: /docs/guides/billing/for-b2b.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing for B2B SaaS allows you to create Plans and manage Subscriptions **for companies or organizations** in your application. If you'd like to charge individual users, see Billing for B2C SaaS. You can also combine both B2C and B2B Billing in the same application.
## Enable Billing
To enable Billing for your application, navigate to the [**Billing Settings**](https://dashboard.clerk.com/~/billing/settings) page in the Clerk Dashboard. This page will guide you through enabling Billing for your application.
Clerk Billing costs the same as using Stripe Billing directly, just 0.7% per transaction, plus transaction fees which are paid directly to Stripe. Clerk Billing is **not** the same as Stripe Billing. Plans and pricing are managed directly through the Clerk Dashboard and won't sync with your existing Stripe products or plans. Clerk uses Stripe **only** for payment processing, so you don't need to set up Stripe Billing.
### Payment gateway
Once you have enabled Billing, you will see the following **Payment gateway** options for collecting payments via Stripe:
* **Clerk development gateway**: A shared **test** Stripe account used for development instances. This allows developers to test and build Billing flows **in development** without needing to create and configure a Stripe account.
* **Stripe account**: Use your own Stripe account for production. **A Stripe account created for a development instance cannot be used for production**. You will need to create a separate Stripe account for your production environment.
## Create a Plan
Subscription Plans are what your customers subscribe to. There is no limit to the number of Plans you can create. If your Clerk instance has existing [Custom Permissions](/docs/guides/organizations/roles-and-permissions), the corresponding Features from those Permissions will automatically be added to the free Plan for Orgs. This ensures that Organization members get the same set of Custom Permissions when Billing is enabled, because all Organizations start on the free Plan.
To create a Plan, navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard. Here, you can create, edit, and delete Plans. To setup B2B Billing, select the **Plans for Organizations** tab and select **Add Plan**. When creating a Plan, you can also create [Features](/docs/guides/secure/features) for the Plan; see the next section for more information.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's an Organization Plan, it can appear in the `` component. When creating or editing a Plan, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Add Features to a Plan
[Features](/docs/guides/secure/features) make it easy to give entitlements to your Plans. You can add any number of Features to a Plan.
You can add a Feature to a Plan when you are creating a Plan. To add it after a Plan is created:
1. Navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard.
2. Select the Plan you'd like to add a Feature to.
3. In the **Features** section, select **Add Feature**.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's an Organization Plan, it can appear in the `` component. When adding a Feature to a Plan, it will also automatically appear in the corresponding Plan. When creating or editing a Feature, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Create a pricing page
You can create a pricing page by using the \ component. This component displays a table of Plans and Features that customers can subscribe to. **It's recommended to create a dedicated page**, as shown in the following example.
```vue {{ filename: 'pages/pricing.vue' }}
```
## Control access with Features, Plans, and Permissions
You can use Clerk's Features, Plans, and Permissions to gate access to content using authorization checksAuthorization checks are checks you perform in your code to determine the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions or access certain content. Learn more about [authorization checks](/docs/guides/secure/authorization-checks).. There are a few ways to do this, but the recommended approach is to either use the has() method or the \ component.
The `has()` method is available for any JavaScript-based framework, while `` is a component, and therefore, is only available for React-based frameworks.
> \[!IMPORTANT]
> Permission-based authorization checks link with Feature-based authorization checks. This means that if you are checking a Custom Permission, it will only work if the Feature part of the Permission key (`org::`) **is a Feature included in the Organization's active Plan**. For example, say you want to check if an Organization member has the Custom Permission `org:teams:manage`, where `teams` is the Feature. Before performing the authorization check, you need to ensure that the user's Organization is subscribed to a Plan that has the `teams` Feature. If the user's Organization is not subscribed to a Plan that has the `teams` Feature, the authorization check will always return `false`, *even if the user has the Custom Permission*.
### Example: Using `has()`
Use the `has()` method to test if the Organization has access to a **Plan**:
```jsx
const hasPremiumAccess = has({ plan: 'gold' })
```
Or a **Feature**:
```jsx
const hasPremiumAccess = has({ feature: 'widgets' })
```
The has() method is a server-side helper that checks if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan) and returns a boolean value. `has()` is available on the auth object, which you will access differently depending on the framework you are using.
> \[!TIP]
> Why aren't Custom Permissions appearing in the session token (JWT) or in API responses (including the result of the `has()` check)?
>
> ***
>
> Custom Permissions will only appear in the session token (JWT) and in API responses (including the result of the `has()` check) if the Feature part of the Permission key (`org::`) **is a Feature included in the Organization's active Plan**. If the Feature is not part of the Plan, the `has()` check for Permissions using that Feature will return `false`, and those Permissions will not be represented in the session token.
>
> For example, say you want to check if an Organization member has the Custom Permission `org:teams:manage`, where `teams` is the Feature. The user's Organization must be subscribed to a Plan that has the `teams` Feature for authorization checks to work. If the user's Organization is not subscribed to a Plan that has the `teams` Feature, the authorization check will always return `false`, *even if the user has the Custom Permission*.
The following example demonstrates how to use `has()` to check if an Organization has a Plan.
```vue {{ filename: 'src/bronze-content.vue' }}
Loading...
Only subscribers to the Bronze plan can access this content.
For Bronze subscribers only
```
The following example demonstrates how to use `has()` to check if an Organization has a Feature.
```vue {{ filename: 'src/premium-content.vue' }}
Loading...
Only subscribers with the Premium Access feature can access this content.
Our Exclusive Content
```
The following example demonstrates how to use `has()` to check if an Organization has a Permission.
```vue {{ filename: 'src/manage-premium-content.vue' }}
Loading...
Only subscribers with the Premium Access Manage permission can access this content.
Our Exclusive Content
```
### Example: Using ``
The \ component protects content or even entire routes by checking if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan). You can pass a `fallback` prop to `` that will be rendered if the Organization does not have the access control.
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Plan.
```vue {{ filename: 'src/protected-content.vue' }}
Exclusive Bronze Content
This content is only visible to Bronze subscribers.
```
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Feature.
```vue {{ filename: 'src/protected-premium-content.vue' }}
Exclusive Premium Content
This content is only visible to users with Premium Access feature.
```
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Permission.
```vue {{ filename: 'src/protected-manage-content.vue' }}
Exclusive Management Content
This content is only visible to users with Premium Access Manage permission.
```
---
title: Clerk Billing for B2C SaaS
description: Clerk Billing is a feature that allows you to create and manage
Plans and Features for your application.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/billing/for-b2c
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: vue
sourceFile: /docs/guides/billing/for-b2c.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing for B2C SaaS allows you to create Plans and manage Subscriptions **for individual users** in your application. If you'd like to charge companies or organizations, see Billing for B2B SaaS. You can also combine both B2C and B2B Billing in the same application.
## Enable Billing
To enable Billing for your application, navigate to the [**Billing Settings**](https://dashboard.clerk.com/~/billing/settings) page in the Clerk Dashboard. This page will guide you through enabling Billing for your application.
Clerk Billing costs the same as using Stripe Billing directly, just 0.7% per transaction, plus transaction fees which are paid directly to Stripe. Clerk Billing is **not** the same as Stripe Billing. Plans and pricing are managed directly through the Clerk Dashboard and won't sync with your existing Stripe products or plans. Clerk uses Stripe **only** for payment processing, so you don't need to set up Stripe Billing.
### Payment gateway
Once you have enabled Billing, you will see the following **Payment gateway** options for collecting payments via Stripe:
* **Clerk development gateway**: A shared **test** Stripe account used for development instances. This allows developers to test and build Billing flows **in development** without needing to create and configure a Stripe account.
* **Stripe account**: Use your own Stripe account for production. **A Stripe account created for a development instance cannot be used for production**. You will need to create a separate Stripe account for your production environment.
## Create a Plan
Subscription Plans are what your users subscribe to. There is no limit to the number of Plans you can create.
To create a Plan, navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard. Here, you can create, edit, and delete Plans. To setup B2C Billing, select the **Plans for Users** tab and select **Add Plan**. When creating a Plan, you can also create Features for the Plan; see the next section for more information.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's a user Plan, it can appear in the `` component. When creating or editing a Plan, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Add Features to a Plan
[Features](/docs/guides/secure/features) make it easy to give entitlements to your Plans. You can add any number of Features to a Plan.
You can add a Feature to a Plan when you are creating a Plan. To add it after a Plan is created:
1. Navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard.
2. Select the Plan you'd like to add a Feature to.
3. In the **Features** section, select **Add Feature**.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's a user Plan, it can appear in the `` component. When adding a Feature to a Plan, it will also automatically appear in the corresponding Plan. When creating or editing a Feature, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Create a pricing page
You can create a pricing page by using the \ component. This component displays a table of Plans and Features that users can subscribe to. **It's recommended to create a dedicated page**, as shown in the following example.
```vue {{ filename: 'pages/pricing.vue' }}
```
## Control access with Features and Plans
You can use Clerk's Features and Plans to gate access to the content. There are a few ways to do this, but the recommended approach is to either use the has() method or the \ component.
The `has()` method is available for any JavaScript framework, while `` is only available for React-based frameworks.
### Example: Using `has()`
Use the `has()` method to test if the user has access to a **Plan**:
```jsx
const hasPremiumAccess = has({ plan: 'gold' })
```
Or a **Feature**:
```jsx
const hasPremiumAccess = has({ feature: 'widgets' })
```
The has() method is a server-side helper that checks if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan) and returns a boolean value. `has()` is available on the auth object, which you will access differently depending on the framework you are using.
The following example demonstrates how to use `has()` to check if a user has a Plan.
```vue {{ filename: 'src/bronze-content.vue' }}
Loading...
Only subscribers to the Bronze plan can access this content.
For Bronze subscribers only
```
The following example demonstrates how to use `has()` to check if a user has a Feature.
```vue {{ filename: 'src/premium-content.vue' }}
Loading...
Only subscribers with the Premium Access feature can access this content.
Our Exclusive Content
```
### Example: Using ``
The \ component protects content or even entire routes by checking if the user has been granted a specific type of access control (Role, Permission, Feature, or Plan). You can pass a `fallback` prop to `` that will be rendered if the user does not have the access control.
The following example demonstrates how to use `` to protect a page by checking if the user has a Plan.
```vue {{ filename: 'src/protected-content.vue' }}
Exclusive Bronze Content
This content is only visible to Bronze subscribers.
```
The following example demonstrates how to use `` to protect a page by checking if the user has a Feature.
```vue {{ filename: 'src/protected-premium-content.vue' }}
Exclusive Premium Content
This content is only visible to users with Premium Access feature.
```
---
title: Clerk Billing webhooks
description: Clerk Billing webhooks allow you to track subscription lifecycles
and monitor payment attempts.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/development/webhooks/billing
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: vue
sourceFile: /docs/guides/development/webhooks/billing.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing supports webhook events that allow you to track information like subscription lifecycles and payments.
## Subscriptions
A subscription is a top-level container unique to each user or organization. Subscription events can help you track billing changes for each of your customers.
| Event Name | Description |
| - | - |
| `subscription.created` | The top-level subscription is created. This usually happens when a user or organization is created. For existing users and organizations, a subscription will be created when Billing is enabled for the application. |
| `subscription.updated` | The top-level subscription is updated. This event is triggered when any property of the subscription has changed, except for status changes. For example, when the subscription items for the payer change. |
| `subscription.active` | The top-level subscription transitions to active from a non-active status. This happens when any subscription item is set to active, including items from the free default Plan. |
| `subscription.pastDue` | The top-level subscription contains a subscription item that has become past due. |
## Subscription items
A subscription item provides details about the relationship between the payer (user or Organization) and a Plan. A top-level subscription may contain multiple subscription items.
There can only be one `active` subscription item per payer and Plan. In addition, the subscription item for the default Plan will always have the same `id` to allow easier tracking of which users and Organizations are not paid customers.
| Event Name | Description |
| - | - |
| `subscriptionItem.updated` | The subscription item is updated. This event is triggered when a property of the subscription item has changed that does not result in a status change. For example, when a subscription item is renewed and the recurring monthly charge succeeds, the status doesn't change (remains `active`), but `period_start` and `period_end` are updated. This results in a `subscriptionItem.updated` event. |
| `subscriptionItem.active` | The subscription item is set to active. For paid Plans, this happens on successful payment. |
| `subscriptionItem.canceled` | The subscription item is canceled. The payer retains Plan features until the end of the current billing period. |
| `subscriptionItem.upcoming` | The subscription item is set as upcoming after the current billing period. This can happen in the case of a deferred Plan change from a higher-priced to lower-priced Plan. In the case a paid Plan is canceled, the subscription item for the default, free Plan will be set as `upcoming`. |
| `subscriptionItem.ended` | The subscription item has ended. |
| `subscriptionItem.abandoned` | The subscription item is abandoned. This can happen to `upcoming` subscription items if the payer subscribes to another Plan, or re-subscribes to a currently canceled Plan. |
| `subscriptionItem.incomplete` | The subscription item is incomplete. This means the payer has started a checkout for a Plan, but the payment hasn't been successfully processed yet. Once payment succeeds, the subscription item transitions to an `active` status. |
| `subscriptionItem.pastDue` | The subscription item is past due because a recurring charge has failed. |
| `subscriptionItem.freeTrialEnding` | The subscription item is a free trial and is ending soon. This event is sent three days before the trial ends. If the trial is shorter than three days, it's sent immediately. |
## Payment attempts
Payment attempts allow you to track successful and failed payments, for both checkout and recurring charges.
Payment attempt events contain a `type`, which can be either `checkout` or `recurring`. You can use these values to determine whether a payment attempt was for a checkout or a subscription item renewal's recurring charge.
| Event Name | Description |
| - | - |
| `paymentAttempt.created` | A payment attempt has been created with `pending` status. It can either succeed or fail in the future. |
| `paymentAttempt.updated` | A payment attempt has been updated to `paid` or `failed` status. |
Looking for other webhook events? To find a list of all the events Clerk supports, navigate to the [**Webhooks**](https://dashboard.clerk.com/~/webhooks) page and select the **Event Catalog** tab.
---
title: Component Reference
description: A list of Clerk's comprehensive suite of components designed to
seamlessly integrate authentication and multi-tenancy into your application.
sdk: react, nextjs, js-frontend, chrome-extension, expo, android, expressjs,
fastify, react-router, remix, tanstack-react-start, go, astro, nuxt, vue,
ruby, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/overview
lastUpdated: 2025-11-21T23:29:30.000Z
availableSdks: react,nextjs,js-frontend,chrome-extension,expo,android,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
notAvailableSdks: ios
activeSdk: vue
sourceFile: /docs/reference/components/overview.mdx
---
Clerk offers a comprehensive suite of components designed to seamlessly integrate authentication and multi-tenancy into your application. With Clerk components, you can easily customize the appearance of authentication components and pages, manage the entire authentication flow to suit your specific needs, and even build robust SaaS applications.
## Authentication components
* \
* \
* \
* \
* \
## User components
* \
* \
* \
## Organization components
* \
* \
* \
* \
## Billing components
* \
* \
* \
* \
## Control components
Control components manage authentication-related behaviors in your application. They handle tasks such as controlling content visibility based on user authentication status, managing loading states during authentication processes, and redirecting users to appropriate pages. Control components render at `` and `` states for assertions on the Clerk object. A common example is the \ component, which allows you to conditionally render content only when a user is authenticated.
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
## Unstyled components
* \
* \
* \
* \
## Customization guides
* [Customize components with the `appearance` prop](/docs/guides/customizing-clerk/appearance-prop/overview)
* [Localize components with the `localization` prop (experimental)](/docs/guides/customizing-clerk/localization)
* [Add pages to the `` component](/docs/guides/customizing-clerk/adding-items/user-profile)
* [Add pages to the `` component](/docs/guides/customizing-clerk/adding-items/organization-profile)
### Secured by Clerk branding
> \[!WARNING]
> This feature requires a [paid plan](/pricing){{ target: '_blank' }} for production use, but all features are free to use in development mode so that you can try out what works for you. See the [pricing](/pricing){{ target: '_blank' }} page for more information.
By default, Clerk displays a **Secured by Clerk** badge on Clerk components. You can remove this branding by following these steps:
1. In the Clerk Dashboard, navigate to your application's [**Settings**](https://dashboard.clerk.com/~/settings).
2. Under **Branding**, toggle on the **Remove "Secured by Clerk" branding** option.
* [Join our Discord](https://clerk.com/discord "Join Discord")
* Join our official Discord server to chat with us directly and become a part of the Clerk community.
* {}
***
* [Need help?](/support "Get help")
* Contact us through Discord, Twitter, or email to receive answers to your questions and learn more about Clerk.
* {}
---
title: "`` component"
description: Clerk's component renders a UI for authenticating
users with Google's One Tap API.
sdk: astro, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/authentication/google-one-tap
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: chrome-extension,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/authentication/google-one-tap.mdx
---
> \[!IMPORTANT]
> To use Google One Tap with Clerk, you must [enable Google as a social connection in the Clerk Dashboard](/docs/guides/configure/auth-strategies/social-connections/google#configure-for-your-production-instance) and make sure to use custom credentials.
The `` component renders the [Google One Tap](https://developers.google.com/identity/gsi/web/guides/features) UI so that users can use a single button to sign-up or sign-in to your Clerk application with their Google accounts.
By default, this component will redirect users back to the page where the authentication flow started. However, you can override this with force redirect URL props or [force redirect URL environment variables](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects).
> \[!TIP]
> `` does not render if the user is already signed into your Clerk application, so there's no need to manually check if a user is signed in yourself before rendering it.
## Example
The following example includes basic implementation of the `` component. You can use this as a starting point for your own implementation.
```vue {{ filename: 'sign-in.vue' }}
```
## Properties
* `cancelOnTapOutside?`
* `boolean`
If `true`, the One Tap prompt closes automatically if the user clicks outside of the prompt. Defaults to `true`.
***
* `itpSupport?`
* `boolean`
If `true`, enables the [ITP-specific UX](https://developers.google.com/identity/gsi/web/guides/itp) when One Tap is rendered on ITP browsers such as Chrome on iOS, Safari, and FireFox. Defaults to `true`.
***
* `fedCmSupport?`
* `boolean`
If `true`, enables Google One Tap to use [the FedCM API](https://developers.google.com/privacy-sandbox/3pcd/fedcm) to sign users in. See Google's docs on [best practices when disabling FedCM support](https://developers.google.com/identity/gsi/web/guides/display-google-one-tap#do_not_cover_google_one_tap). Defaults to `true`
***
* `signInForceRedirectUrl?`
* `string`
Useful if you want to redirect to a path specific to Google One Tap users. If provided, this URL will **always** be redirected to after the user signs in, overriding any \ redirect URL props or [redirect URL environment variables](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects).
***
* `signUpForceRedirectUrl?`
* `string`
Useful if you want to redirect to a path specific to Google One Tap users. If provided, this URL will **always** be redirected to after the user signs up, overriding any \ redirect URL props or [redirect URL environment variables](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects).
## Limitations
* If your application will use the Google API on behalf of your users, the `` component is not recommended, as Google does not provide Clerk with an access or refresh token that you can use.
* Users with the 1Password browser extension may not be able to render the Google One Tap UI. They must disable this extension.
* When testing in development, if you select the `X` button to close the Google One Tap UI, you may encounter [a cooldown](https://developers.google.com/identity/gsi/web/guides/features#exponential_cooldown) that prevents you from rendering it again for a period of time. To bypass the cooldown, remove the `g_state` cookie.
---
title: "`` component"
description: Clerk's component renders a UI for signing in users.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/authentication/sign-in
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/authentication/sign-in.mdx
---
{{ style: { maxWidth: '460px' } }}
The `` component renders a UI to allow users to sign in or sign up by default. The functionality of the `` component is controlled by the instance settings you specify in the [Clerk Dashboard](https://dashboard.clerk.com), such as [sign-in and sign-up options](/docs/guides/configure/auth-strategies/sign-up-sign-in-options) and [social connections](/docs/guides/configure/auth-strategies/social-connections/all-providers). You can further customize your `` component by passing additional properties at the time of rendering.
> \[!NOTE]
> The `` and `` components cannot render when a user is already signed in, unless the application allows multiple sessions. If a user is already signed in and the application only allows a single session, Clerk will redirect the user to the Home URL instead.
## Example
The following example includes basic implementation of the `` component. You can use this as a starting point for your own implementation.
```vue {{ filename: 'sign-in.vue' }}
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `fallbackRedirectUrl`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `forceRedirectUrl`
* `string`
If provided, this URL will always be redirected to after the user signs in. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `initialValues`
* SignInInitialValues
The values used to prefill the sign-in fields with.
***
* `oauthFlow`
* `"redirect" | "popup" | "auto"`
Determines how OAuth authentication is performed. Accepts the following properties:
* `"redirect"`: Redirect to the OAuth provider on the current page.
* `"popup"`: Open a popup window.
* `"auto"`: Choose the best method based on whether the current domain typically requires the `"popup"` flow to correctly perform authentication.
Defaults to `"auto"`.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash-based routing. For example: `/sign-in`.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
***
* `signUpFallbackRedirectUrl`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Used for the 'Don't have an account? Sign up' link that's rendered. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpForceRedirectUrl`
* `string`
If provided, this URL will always used as the redirect destination after the user signs up. Used for the 'Don't have an account? Sign up' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpUrl`
* `string`
The full URL or path to the sign-up page. Used for the 'Don't have an account? Sign up' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `transferable`
* `boolean`
Indicates whether or not sign in attempts are transferable to the sign up flow. Defaults to `true`. When set to `false`, prevents opaque sign ups when a user attempts to sign in via OAuth with an email that doesn't exist.
***
* `waitlistUrl`
* `string`
Full URL or path to the waitlist page. Use this property to provide the target of the 'Waitlist' link that's rendered. If `undefined`, will redirect to the [Account Portal waitlist page](/docs/guides/customizing-clerk/account-portal#waitlist). If you've passed the `waitlistUrl` prop to the \ component, it will infer from that, and you can omit this prop.
***
* `withSignUp`
* `boolean`
Opt into sign-in-or-up flow by setting this prop to `true`. When `true`, if a user does not exist, they will be prompted to sign up. If a user exists, they will be prompted to sign in. Defaults to `true` if the `CLERK_SIGN_IN_URL` environment variable is set. Otherwise, defaults to `false`.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
If Clerk's prebuilt components don't meet your specific needs or if you require more control over the logic, you can rebuild the existing Clerk flows using the Clerk API. For more information, see the [custom flow guides](/docs/guides/development/custom-flows/overview).
---
title: "`` component"
description: Clerk's component renders a UI for signing up users.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/authentication/sign-up
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/authentication/sign-up.mdx
---
{{ style: { maxWidth: '460px' } }}
The `` component renders a UI for signing up users. The functionality of the `` component is controlled by the instance settings you specify in the [Clerk Dashboard](https://dashboard.clerk.com), such as [sign-in and sign-up options](/docs/guides/configure/auth-strategies/sign-up-sign-in-options) and [social connections](/docs/guides/configure/auth-strategies/social-connections/all-providers). You can further customize your `` component by passing additional properties at the time of rendering.
> \[!NOTE]
> The `` and `` components cannot render when a user is already signed in, unless the application allows multiple sessions. If a user is already signed in and the application only allows a single session, Clerk will redirect the user to the Home URL instead.
## Example
The following example includes basic implementation of the `` component. You can use this as a starting point for your own implementation.
```vue {{ filename: 'sign-up.vue' }}
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `fallbackRedirectUrl`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `forceRedirectUrl`
* `string`
If provided, this URL will always be used as the redirect destination after the user signs up. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `initialValues`
* SignUpInitialValues
The values used to prefill the sign-up fields with.
***
* `oauthFlow`
* `"redirect" | "popup" | "auto"`
Determines how OAuth authentication is performed. Accepts the following properties:
* `"redirect"`: Redirect to the OAuth provider on the current page.
* `"popup"`: Open a popup window.
* `"auto"`: Choose the best method based on whether the current domain typically requires the `"popup"` flow to correctly perform authentication.
Defaults to `"auto"`.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash-based routing. For example: `/sign-up`.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
***
* `signInFallbackRedirectUrl`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Used for the 'Already have an account? Sign in' link that's rendered. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signInForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs in. Used for the 'Already have an account? Sign in' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signInUrl`
* `string`
The full URL or path to the sign-in page. Used for the 'Already have an account? Sign in' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `unsafeMetadata`
* SignUpUnsafeMetadata
Metadata that can be read and set from the frontend and the backend. Once the sign-up is complete, the value of this field will be automatically copied to the created user's unsafe metadata (`User.unsafeMetadata`). One common use case is to collect custom information about the user during the sign-up process and store it in this property. Read more about [unsafe metadata](/docs/guides/users/extending#unsafe-metadata).
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
If Clerk's prebuilt components don't meet your specific needs or if you require more control over the logic, you can rebuild the existing Clerk flows using the Clerk API. For more information, see the [custom flow guides](/docs/guides/development/custom-flows/overview).
---
title: "`` component"
description: The component renders a waitlist form that allows
users to join for early access to your application.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/authentication/waitlist
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/authentication/waitlist.mdx
---
{{ style: { maxWidth: '460px' } }}
In **Waitlist** mode, users can register their interest in your app by joining a waitlist. This mode is ideal for apps in early development stages or those wanting to generate interest before launch. [Learn more about additional features available in **Waitlist** mode](/docs/guides/secure/restricting-access#waitlist).
The `` component renders a form that allows users to join for early access to your app.
## Enable Waitlist mode
Before using the `` component, you must enable **Waitlist** mode in the Clerk Dashboard:
1. In the Clerk Dashboard, navigate to the [**Restrictions**](https://dashboard.clerk.com/~/user-authentication/restrictions) page.
2. Under the **Sign-up modes** section, enable **Waitlist**.
## Example
> \[!WARNING]
> Before using the `` component, you must provide the `waitlistUrl` prop either in the \ or \ component to ensure proper functionality.
The following example includes a basic implementation of the `` component. You can use this as a starting point for your own implementation.
```vue {{ filename: 'waitlist.vue' }}
```
## Properties
All props are optional.
* `afterJoinWaitlistUrl`
* `string`
The full URL or path to navigate to after joining the waitlist.
***
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `signInUrl`
* `string`
The full URL or path to the sign in page. Used for the 'Already have an account? Sign in' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
## Customization
To learn about how to customize Clerk components, see the [customization guide](/docs/guides/customizing-clerk/appearance-prop/overview).
---
title: "`` component"
description: Clerk's component renders a button that opens
the checkout drawer for Plan subscriptions.
sdk: react, nextjs, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/billing/checkout-button
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: react,nextjs,vue
notAvailableSdks: js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/billing/checkout-button.mdx
---

The `` component renders a button that opens the checkout drawer when selected, allowing users to subscribe to a Plan for either their Personal Account or an Organization. It must be wrapped inside a \ component to ensure the user is authenticated.
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
## Usage
`` must be wrapped inside a \ component to ensure the user is authenticated.
```tsx
<>
// ❌ This will throw an error
// ✅ Correct usage
>
```
`` will throw an error if the `for` prop is set to `'organization'` and no Active OrganizationA user can be a member of multiple Organizations, but only one can be active at a time. The **Active Organization** determines which Organization-specific data the user can access and which Role and related Permissions they have within the Organization. is set.
```tsx
<>
// ❌ This will throw an error if no Organization is active
// ✅ Correct usage
{auth.orgId ? : null}
>
```
`` preserves any click handlers attached to custom button elements, while maintaining the checkout drawer functionality.
```tsx
```
### Examples
```vue {{ filename: 'pricing.vue' }}
```
## Properties
* `planId`
* `string`
The ID of the Plan to subscribe to.
***
* `planPeriod?`
* `'month' | 'annual'`
The billing period for the subscription.
***
* `for?`
* `'user' | 'organization'`
Determines whether the subscription is for the current user or Organization. Defaults to `'user'`.
***
* `children?`
* `React.ReactNode`
A custom button element. If not provided, defaults to a button with the text "Checkout".
***
* `onSubscriptionComplete?`
* `() => void`
A callback function that is called when a subscription is successfully completed.
***
* `newSubscriptionRedirectUrl?`
* `string`
The URL to redirect to after a successful subscription.
***
* `checkoutProps?`
* `{ appearance: Appearance }`
Options for the checkout drawer. Accepts the following properties:
* [`appearance`](/docs/guides/customizing-clerk/appearance-prop/overview): an object used to style your components. For example: ``.
---
title: "`` component"
description: Clerk's component renders a button that opens
the Plan details drawer.
sdk: react, nextjs, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/billing/plan-details-button
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: react,nextjs,vue
notAvailableSdks: js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/billing/plan-details-button.mdx
---
{{ style: { maxWidth: '460px' } }}
The `` component renders a button that opens the Plan details drawer, allowing users to view detailed information about a specific Plan, including pricing, Features, and other Plan-specific details.
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
## Usage
`` preserves any click handlers attached to custom button elements, while maintaining the Plan details drawer functionality.
```tsx
```
`` supports rendering the Plan details drawer in a custom portal container.
```tsx {{ prettier: false }}
const portalRoot = document.getElementById('custom-portal')
```
### Examples
```vue {{ filename: 'pricing.vue' }}
```
## Properties
* `planId?`
* `string`
The ID of the Plan to display details for. It is required if `plan` is not provided.
***
* `plan?`
* BillingPlanResource
The Plan to display details for. It is used as initial data until the Plan is fetched from the server.
***
* `children?`
* `React.ReactNode`
Optional custom button element. If not provided, defaults to a button with the text "Plan details".
***
* `initialPlanPeriod?`
* `'month' | 'annual'`
Optional prop to set the initial billing period view when the Plan details drawer opens.
***
* `planDetailsProps?`
* `{ appearance: Appearance }`
Options for the Plan details drawer. Accepts the following properties:
* [`appearance`](/docs/guides/customizing-clerk/appearance-prop/overview): an object used to style your components. For example: ``.
---
title: "`` component"
description: Clerk's component renders a button
that opens the subscription details drawer.
sdk: react, nextjs, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/billing/subscription-details-button
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: react,nextjs,vue
notAvailableSdks: js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/billing/subscription-details-button.mdx
---

The `` component renders a button that opens the subscription details drawer when selected, allowing users to view and manage their subscription details, whether for their Personal Account or Organization. It must be wrapped inside a \ component to ensure the user is authenticated.
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
## Usage
`` must be wrapped inside a \ component to ensure the user is authenticated.
```tsx
<>
// ❌ This will throw an error
// ✅ Correct usage
>
```
`` will throw an error if the `for` prop is set to `'organization'` and no Active OrganizationA user can be a member of multiple Organizations, but only one can be active at a time. The **Active Organization** determines which Organization-specific data the user can access and which Role and related Permissions they have within the Organization. is set.
```tsx
<>
// ❌ This will throw an error if no Organization is active
// ✅ Correct usage
{auth.orgId ? : null}
>
```
### Examples
```vue {{ filename: 'billing.vue' }}
```
## Properties
All props are optional.
* `for?`
* `'user' | 'organization'`
Determines whether to show subscription details for the current user or Organization. Defaults to `'user'`.
***
* `children?`
* `React.ReactNode`
Optional custom button element. If not provided, defaults to a button with the text "Subscription details".
***
* `onSubscriptionCancel?`
* `() => void`
A callback function that is called when a subscription is cancelled.
***
* `subscriptionDetailsProps?`
* `{ appearance: Appearance }`
Options for the subscription details drawer. Accepts the following properties:
* [`appearance`](/docs/guides/customizing-clerk/appearance-prop/overview): an object used to style your components. For example: ``.
---
title: "``"
description: Clerk's component displays a table of Plans and
Features that users can subscribe to.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/billing/pricing-table
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/billing/pricing-table.mdx
---

The `` component displays a table of Plans and Features that users can subscribe to.
## Example
The following example includes a basic implementation of the `` component. You can use this as a starting point for your own implementation.
```vue {{ filename: 'pricing.vue' }}
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `checkoutProps`
* `{ appearance: Appearance }`
Options for the checkout drawer. Accepts the following properties:
* [`appearance`](/docs/guides/customizing-clerk/appearance-prop/overview): an object used to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `collapseFeatures`
* `boolean`
A boolean that indicates whether the Features are collapsed. **Requires `layout` to be set to `'default'`**. Defaults to `false`.
***
* `ctaPosition`
* `'top' | 'bottom'`
The placement of the CTA button. **Requires `layout` to be set to `'default'`**. Defaults to `'bottom'`.
***
* `fallback`
* `JSX`
An optional UI to show when the pricing table is loading.
***
* `for`
* `'user' | 'organization'`
A string that indicates whether the pricing table is for users or [Organizations](/docs/guides/organizations/overview). If `'user'`, the pricing table will display a list of Plans and Features that **users** can subscribe to. If `'organization'`, the pricing table will display a list of Plans and Features that **Organizations** can subscribe to. Defaults to `'user'`.
***
* `newSubscriptionRedirectUrl`
* `string`
The URL to navigate to after the user completes the checkout and selects the "Continue" button.
---
title: \RedirectCallback />
description: Clerk's `` component is used to
implement custom OAuth flows. It handles the OAuth callback and completes the
authentication process.
sdk: astro, chrome-extension, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/authenticate-with-redirect-callback
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: expo,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/control/authenticate-with-redirect-callback.mdx
---
The `` component is a crucial part of implementing custom OAuth flows in your application. It serves as the callback handler for the authentication process initiated by the `authenticateWithRedirect()` method. Render it on the route specified as the `redirectUrl` in your `authenticateWithRedirect()` call.
This component automatically handles the OAuth callback, completing the authentication process and managing the user's session. It uses the handleRedirectCallback() method under the hood.
## Example
For an example of how to use the `` component, see the [custom flow](/docs/guides/development/custom-flows/authentication/oauth-connections) guide.
## Properties
All props are optional.
* `continueSignUpUrl?`
* `string | undefined | null`
The full URL or path to navigate to if the sign up requires additional information.
***
* `signInUrl?`
* `string`
The full URL or path where the `` component is mounted.
***
* `signUpUrl?`
* `string`
The full URL or path where the `` component is mounted.
***
* `signInFallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpFallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signInForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs in. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs up. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `firstFactorUrl?`
* `string | undefined`
The full URL or path to navigate to during sign in, if first factor verification is required.
***
* `secondFactorUrl?`
* `string | undefined`
The full URL or path to navigate to during sign in, if [multi-factor authentication](/docs/guides/configure/auth-strategies/sign-up-sign-in-options#multi-factor-authentication) is enabled.
***
* `resetPasswordUrl?`
* `string`
The full URL or path to navigate to during sign in, if the user is required to reset their password.
***
* `transferable?`
* `boolean`
A boolean that indicates whether or not sign in attempts are transferable to the sign up flow. Defaults to `true`. When set to `false`, prevents opaque sign ups when a user attempts to sign in via OAuth with an email that doesn't exist.
***
* `verifyEmailAddressUrl?`
* `string | undefined | null`
The full URL or path to navigate to after requesting email verification.
***
* `verifyPhoneNumberUrl?`
* `string | undefined | null`
The full URL or path to navigate to after requesting phone verification.
---
title: "``"
description: The `` renders its children while Clerk is loading,
and is helpful for showing a custom loading state.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/clerk-loading
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/control/clerk-loading.mdx
---
The `` renders its children while Clerk is loading, and is helpful for showing a custom loading state.
## Example
It's not recommended to wrap the entire app in the `` component; instead, only wrap the components that need access to the `Clerk` object.
```vue {{ filename: 'App.vue' }}
Clerk is loading
Clerk has loaded
```
---
title: "``"
description: The Protect component protects content or even entire routes based
on authentication, and optionally, authorization. It only renders its children
when the current user is signed-in, and if performing authorization checks, if
the user has been granted a specific type of access control (Role, Permission,
Feature, or Plan).
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/protect
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/control/protect.mdx
---
The \ component protects content or even entire routes based on:
* authentication: whether the user is signed-in or not.
* authorization: whether the user has been granted a specific type of access control (Role, Permission, Feature, or Plan)
`` **always** performs authentication checks. To perform authorization checksAuthorization checks are checks you perform in your code to determine the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions or access certain content. Learn more about [authorization checks](/docs/guides/secure/authorization-checks)., you can pass different props, like `role`, `permission`, `feature`, or `plan`.
`` accepts a `fallback` prop that will be rendered if the user fails the authentication or authorization checks.
`` can be used both client-side and server-side (in Server Components).
> \[!CAUTION]
> This component only **visually hides** its children when the current user is not authorized. The contents of its children remain accessible via the browser's source code even if the user fails the authorization check. Do not use this component to hide sensitive information that should be completely inaccessible to unauthorized users. For truly sensitive data, perform authorization checksAuthorization checks are checks you perform in your code to determine the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions or access certain content. Learn more about [authorization checks](/docs/guides/secure/authorization-checks). on the server before sending the data to the client.
## Usage
### Authentication checks
`` always performs authentication checks. It will render its children if the user is signed-in, and its `fallback` prop if the user is signed-out.
```vue
Users that are signed-out can see this.
Users that are signed-in can see this.
```
### Authorization checks
To limit who is able to see the content that `` renders, you can pass **one** of the access control props: `permission`, `role`, `feature`, or `plan`. It's recommended to use **Permission-based** authorization over **Role-based** authorization, and **Feature-based** authorization over **Plan-based** authorization, as they are more flexible, easier to manage, and more secure.
If you do not pass any of the access control props, `` will render its children if the user is signed in, regardless of their Role or its Permissions.
For more complex authorization logic, pass conditional logic to the `condition` prop.
### Render content by Permissions
The following example demonstrates how to use the `` component to protect content by checking if the user has the `org:invoices:create` Permission.
```vue
You do not have the Permissions to create an invoice.
Users with Permission org:invoices:create can see this.
```
### Render content by Role
While authorization by `permission` is **recommended**, for convenience, `` allows a `role` prop to be passed.
The following example demonstrates how to use the `` component to protect content by checking if the user has the `org:billing` Role.
```vue
Only a member of the Billing department can access this content.
Users with Role org:billing can see this.
```
### Render content by Plan
The following example demonstrates how to use `` to protect content by checking if the user has a Plan.
```vue
Sorry, only subscribers to the Bronze plan can access this content.
Welcome, Bronze subscriber!
```
### Render content by Feature
The following example demonstrates how to use `` to protect content by checking if the user has a Feature.
```vue
Sorry, only subscribers with the Premium Access feature can access this content.
Congratulations! You have access to the Premium Access feature.
```
### Render content conditionally
The following example uses ``'s `condition` prop to conditionally render its children if the user has the correct Role.
```vue
Only an Admin or Billing Manager can access this content.
The settings page.
```
## Properties
* `condition?`
* `has => boolean`
Optional conditional logic that renders the children if it returns `true`.
***
* `fallback?`
* `JSX`
Optional UI to show when a user doesn't have the correct type of access control to access the protected content.
***
* `feature?`
* `string`
Optional string corresponding to a [Feature](/docs/guides/billing/overview).
***
* `plan?`
* `string`
Optional string corresponding to a [Plan](/docs/guides/billing/overview).
***
* `permission?`
* `string`
Optional string corresponding to a [Permission](/docs/guides/organizations/roles-and-permissions) in the format `org::`
***
* `role?`
* `string`
Optional string corresponding to a [Role](/docs/guides/organizations/roles-and-permissions) in the format `org:`
***
* `treatPendingAsSignedOut?`
* `boolean`
A boolean that indicates whether to treat pending sessions as signed out. Defaults to `true`.
---
title: "`` (deprecated)"
description: The component will navigate to the
create Organization flow which has been configured in your application
instance. The behavior will be just like a server-side (3xx) redirect, and
will override the current location in the history stack.
sdk: nextjs, nuxt, react, react-router, remix, tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/redirect-to-create-organization
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/control/redirect-to-create-organization.mdx
---
> \[!WARNING]
> This feature is deprecated. Please use the redirectToCreateOrganization() method instead.
The `` component will navigate to the create Organization flow which has been configured in your application instance. The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.
## Example
```vue {{ filename: 'App.vue' }}
You need to sign in to create an Organization.
```
---
title: "``"
description: The component will navigate to the sign up URL
which has been configured in your application instance. The behavior will be
just like a server-side (3xx) redirect, and will override the current location
in the history stack.
sdk: chrome-extension, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/redirect-to-sign-up
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: chrome-extension,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,expo,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/control/redirect-to-sign-up.mdx
---
The `` component will navigate to the sign up URL which has been configured in your application instance. The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.
## Example
```vue {{ filename: 'App.vue' }}
```
---
title: "`` (deprecated)"
description: The component will navigate to
the Organization profile URL which has been configured in your application
instance. The behavior will be just like a server-side (3xx) redirect, and
will override the current location in the history stack.
sdk: nextjs, nuxt, react, react-router, remix, tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/redirect-to-organization-profile
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/control/redirect-to-organization-profile.mdx
---
> \[!WARNING]
> This feature is deprecated. Please use the redirectToOrganizationProfile() method instead.
The `` component will navigate to the Organization profile URL which has been configured in your application instance. The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.
## Example
```vue {{ filename: 'App.vue' }}
You need to sign in to view your Organization profile.
```
---
title: "``"
description: The component will navigate to the sign in URL
which has been configured in your application instance. The behavior will be
just like a server-side (3xx) redirect, and will override the current location
in the history stack.
sdk: chrome-extension, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/redirect-to-sign-in
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: chrome-extension,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,expo,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/control/redirect-to-sign-in.mdx
---
The `` component will navigate to the sign in URL which has been configured in your application instance. The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.
## Example
```vue {{ filename: 'App.vue' }}
```
---
title: "``"
description: The `` component guarantees that the Clerk object has
loaded and will be available under `window.Clerk`. This allows you to wrap
child components to access the Clerk object without the need to check it
exists.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/clerk-loaded
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/control/clerk-loaded.mdx
---
The `` component guarantees that the Clerk object has loaded (the `status` is `'ready'` or `'degraded'`) and will be available under `window.Clerk`. This allows you to wrap child components to access the `Clerk` object without the need to check it exists.
## Example
It's not recommended to wrap the entire app in the `` component; instead, only wrap the components that need access to the `Clerk` object.
```vue {{ filename: 'App.vue' }}
Clerk has loaded
```
---
title: "``"
description: The component will navigate to the tasks flow
which has been configured in your application instance when users have pending
session tasks. The behavior will be just like a server-side (3xx) redirect,
and will override the current location in the history stack.
sdk: chrome-extension, nextjs, nuxt, react, react-router, tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/redirect-to-tasks
lastUpdated: 2025-11-21T22:25:46.000Z
availableSdks: chrome-extension,nextjs,nuxt,react,react-router,tanstack-react-start,vue
notAvailableSdks: js-frontend,expo,android,ios,expressjs,fastify,remix,go,astro,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/control/redirect-to-tasks.mdx
---
The `` component will navigate to the tasks flow which has been configured in your application instance when users have pending session tasks**Session tasks** are requirements that users must fulfill in order to complete the authentication process, such as choosing an Organization.. The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.
The `` component is primarily intended for use in custom flowsA **custom flow** refers to a user interface built entirely from scratch using the Clerk API. Learn more about [custom flows](/docs/guides/development/custom-flows/overview).. If you're using prebuilt components, you typically won't need to use `` as these components manage task redirection internally. [See the guide on handling session tasks outside of prebuilt components](/docs/guides/configure/session-tasks#redirecting-to-tasks).
## Example
```vue {{ filename: 'App.vue' }}
```
---
title: "``"
description: Conditionally render content only when a user is signed in.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/signed-in
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/control/signed-in.mdx
---
## Overview
The `` component offers authentication checks as a cross-cutting concern. Any children components wrapped by a `` component will be rendered only if there's a user with an active session signed in your application.
> \[!CAUTION]
> This component only **visually hides** its children when the current user is not authenticated. The contents of its children remain accessible via the browser's source code even if the user fails the authentication check. Do not use this component to hide sensitive information that should be completely inaccessible to unauthorized users. For truly sensitive data, perform authorization checksAuthorization checks are checks you perform in your code to determine the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions or access certain content. Learn more about [authorization checks](/docs/guides/secure/authorization-checks). on the server before sending the data to the client.
## Example
```vue {{ filename: 'App.vue' }}
You are signed in.
This content is always visible.
```
## Properties
* `treatPendingAsSignedOut?`
* `boolean`
A boolean that indicates whether to treat pending sessions as signed out. Defaults to `true`.
---
title: "`` (deprecated)"
description: The component will navigate to the user
profile URL which has been configured in your application instance. The
behavior will be just like a server-side (3xx) redirect, and will override the
current location in the history stack.
sdk: nextjs, nuxt, react, react-router, remix, tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/redirect-to-user-profile
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/control/redirect-to-user-profile.mdx
---
> \[!WARNING]
> This feature is deprecated. Please use the redirectToUserProfile() method instead.
The `` component will navigate to the Account Portal User Profile URL which has been configured in your application instance. The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.
To find your User Profile URL:
1. In the Clerk Dashboard, navigate to the [**Account Portal**](https://dashboard.clerk.com/~/account-portal) page.
2. Under **User profile**, select the **Visit** icon.
## Example
```vue {{ filename: 'App.vue' }}
You need to sign in to view your user profile.
```
---
title: "``"
description: Conditionally render content only when a user is signed out.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/signed-out
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/control/signed-out.mdx
---
The `` component offers authentication checks as a cross-cutting concern. Any child nodes wrapped by a `` component will be rendered only if there's no User signed in to your application.
## Example
```vue {{ filename: 'App.vue' }}
You are signed out.
This content is always visible.
```
## Properties
* `treatPendingAsSignedOut?`
* `boolean`
A boolean that indicates whether to treat pending sessions as signed out. Defaults to `true`.
---
title: "`` component"
description: Clerk's component is used to render an
Organization creation UI that allows users to create brand new Organizations
within your application.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/organization/create-organization
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/organization/create-organization.mdx
---
{{ style: { maxWidth: '492px' } }}
The `` component is used to render an Organization creation UI that allows users to create brand new Organizations in your application.
## Example
The following example includes a basic implementation of the `` component. You can use this as a starting point for your own implementation.
```vue {{ filename: 'create-organization.vue' }}
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `afterCreateOrganizationUrl`
* `string`
Full URL or path to navigate to after creating a new organization.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash-based routing. For example: `/create-organization`.
***
* `skipInvitationScreen`
* `boolean`
Hides the screen for sending invitations after an Organization is created. When left undefined, Clerk will automatically hide the screen if the number of max allowed members is equal to 1
***
* `hideSlug`
* `boolean`
Hides the optional slug field in the Organization creation screen.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
---
title: "`` component"
description: Clerk's component is used to display
Organization related memberships, invitations, and suggestions for the user.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/organization/organization-list
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/organization/organization-list.mdx
---
{{ style: { maxWidth: '460px' } }}
The `` component displays Organization-related memberships and automatic [invitations](/docs/guides/organizations/verified-domains#automatic-invitations) and [suggestions](/docs/guides/organizations/verified-domains#automatic-suggestions) for the user.
## Example
```vue {{ filename: 'organizations.vue' }}
```
## Properties
The `` component accepts the following properties, all of which are **optional**:
* `afterCreateOrganizationUrl`
* ((org: Organization) => string) | string
The full URL or path to navigate to after creating a new Organization.
***
* `afterSelectOrganizationUrl`
* ((org: Organization) => string) | string
The full URL or path to navigate to after selecting an Organization. Defaults to `undefined`.
***
* `afterSelectPersonalUrl`
* ((org: Organization) => string) | string
The full URL or path to navigate to after selecting the [Personal Account](/docs/guides/organizations/overview#allow-personal-accounts). Defaults to `undefined`.
***
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `hidePersonal`
* `boolean`
A boolean that controls whether `` will include the user's [Personal Account](/docs/guides/organizations/overview#allow-personal-accounts) in the Organization list. Setting this to `true` will hide the Personal Account option, and users will only be able to switch between Organizations. Defaults to `false`.
***
* `hideSlug`
* `boolean`
A boolean that controls whether the optional slug field in the Organization creation screen is hidden. Defaults to `false`.
***
* `skipInvitationScreen`
* `boolean | undefined`
A boolean that controls whether the screen for sending invitations after an Organization is created is hidden. When `undefined`, Clerk will automatically hide the screen if the number of max allowed members is equal to 1. Defaults to `false`.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
[org-ref]: /docs/reference/javascript/organization
---
title: "`` component"
description: Clerk's component is used to render a
beautiful, full-featured Organization management UI that allows users to
manage their Organization profile and security settings.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/organization/organization-profile
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/organization/organization-profile.mdx
---

The `` component allows users to manage their Organization membership, security, and billing settings.
This component's **General** tab displays the Organization's information and the **Leave organization** button. Admins will be able to see the **Update profile** button, **Verified domains** section, and **Delete organization** button.
The **Members** tab shows the Organization's members along with their join dates and Roles. Admins will have the ability to invite a member, change a member's Role, or remove them from the Organization. Admins will have tabs within the **Members** tab to view the Organization's [invitations](/docs/guides/organizations/overview#organization-invitations) and [requests](/docs/guides/organizations/verified-domains#membership-requests).
The **Billing** tab displays the Plans and Features that are available to the Organization, as well as the user's billing information, such as their invoices and payment methods.
## Example
```vue {{ filename: 'organization-profile.vue' }}
```
## Properties
The `` component accepts the following properties, all of which are **optional**:
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `afterLeaveOrganizationUrl`
* `string`
The full URL or path to navigate to after leaving an Organization.
***
* `customPages`
* `CustomPages[]`
An array of custom pages to add to the Organization profile. Only available for the JavaScript SDK. To add custom pages with React-based SDK's, see the [dedicated guide](/docs/guides/customizing-clerk/adding-items/organization-profile).
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash- and virtual-based routing. For example: `/organization-profile`.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
In addition, you also can add custom pages and links to the `` navigation sidenav. For more information, refer to the [Custom Pages](/docs/guides/customizing-clerk/adding-items/organization-profile) documentation.
---
title: "`` component"
description: Clerk's component is used to enable the
ability to switch between available Organizations the user may be part of in
your application.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/organization/organization-switcher
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/organization/organization-switcher.mdx
---
{{ style: { maxWidth: '436px' } }}
The `` component allows a user to switch between their joined Organizations. If [Personal Accounts are enabled](/docs/guides/organizations/overview#allow-personal-accounts), users can also switch to their Personal Account. This component is useful for applications that have a multi-tenant architecture, where users can be part of multiple Organizations. It handles all Organization-related flows, including full Organization management for admins. Learn more about [Organizations](/docs/guides/organizations/overview).
## Example
```vue {{ filename: 'organization-switcher.vue' }}
```
## Properties
The `` component accepts the following properties, all of which are **optional**:
* `afterCreateOrganizationUrl`
* `string`
The full URL or path to navigate to after creating a new Organization.
***
* `afterLeaveOrganizationUrl`
* `string`
The full URL or path to navigate to after the user leaves the currently Active OrganizationA user can be a member of multiple Organizations, but only one can be active at a time. The **Active Organization** determines which Organization-specific data the user can access and which Role and related Permissions they have within the Organization..
***
* `afterSelectOrganizationUrl`
* `string`
The full URL or path to navigate to after a successful Organization switch.
***
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `createOrganizationMode`
* `'modal' | 'navigation'`
A boolean that controls whether clicking the "Create organization" button will cause the \ component to open as a modal, or if the browser will navigate to the `createOrganizationUrl` where `` is mounted as a page. Defaults to: `'modal'`.
***
* `createOrganizationUrl`
* `string`
The full URL or path where the ``]createorg-ref component is mounted.
***
* `defaultOpen`
* `boolean`
A boolean that controls the default state of the `` component.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `hidePersonal`
* `boolean`
A boolean that controls whether `` will include the user's [Personal Account](/docs/guides/organizations/overview#allow-personal-accounts) in the Organization list. Setting this to `true` will hide the Personal Account option, and users will only be able to switch between Organizations. Defaults to `false`.
***
* `hideSlug`
* `boolean`
A boolean that controls whether the optional slug field in the Organization creation screen is hidden.
***
* `organizationProfileMode`
* `'modal' | 'navigation'`
A boolean that controls whether clicking the **Manage organization** button will cause the \ component to open as a modal, or if the browser will navigate to the `organizationProfileUrl` where `` is mounted as a page. Defaults to: `'modal'`.
***
* `organizationProfileProps`
* `object`
Specify options for the underlying \ component. For example: `{appearance: {...}}`
***
* `organizationProfileUrl`
* `string`
The full URL or path where the \ component is mounted.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
[createorg-ref]: /docs/reference/components/organization/create-organization
[orgprofile-ref]: /docs/reference/components/organization/organization-profile
---
title: "``"
description: The `` component is used to complete a
one-click, cryptographically-secure sign-in flow using MetaMask.
sdk: expo, nextjs, nuxt, react, react-router, remix, tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/unstyled/sign-in-with-metamask
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,chrome-extension,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/unstyled/sign-in-with-metamask.mdx
---
The `` component is used to complete a one-click, cryptographically-secure sign-in flow using MetaMask.
## Usage
### Basic usage
```vue {{ filename: 'example.vue' }}
```
### Custom usage
In some cases, you will want to use your own button, or button text. You can do that by wrapping your button in the `` component.
```vue {{ filename: 'example.vue' }}
```
---
title: "``"
description: The component is a button that links to the sign-up
page or displays the sign-up modal.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/unstyled/sign-up-button
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/unstyled/sign-up-button.mdx
---
The `` component is a button that, by default, links to your app's sign-up page. Your sign-up page will be hosted by Clerk using the [Account Portal](/docs/guides/customizing-clerk/account-portal) unless you have set up a dedicated sign-up page.
## Usage
### Basic usage
```vue {{ filename: 'src/App.vue' }}
```
### Custom usage
You can create a custom button by wrapping your own button, or button text, in the `` component.
```vue {{ filename: 'src/App.vue' }}
```
## Properties
* `forceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs up. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `fallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `oauthFlow`
* `"redirect" | "popup" | "auto"`
Determines how OAuth authentication is performed. Accepts the following properties:
* `"redirect"`: Redirect to the OAuth provider on the current page.
* `"popup"`: Open a popup window.
* `"auto"`: Choose the best method based on whether the current domain typically requires the `"popup"` flow to correctly perform authentication.
Defaults to `"auto"`.
***
* `signInForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs in. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signInFallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `mode?`
* `'redirect' | 'modal'`
Determines what happens when a user clicks on the ``. Setting this to `'redirect'` will redirect the user to the sign-up route. Setting this to `'modal'` will open a modal on the current route. Defaults to `'redirect'`
***
* `children?`
* `React.ReactNode`
Children you want to wrap the `` in.
***
* `initialValues`
* SignUpInitialValues
The values used to prefill the sign-up fields with.
***
* `unsafeMetadata`
* SignUpUnsafeMetadata
Metadata that can be read and set from the frontend and the backend. Once the sign-up is complete, the value of this field will be automatically copied to the created user's unsafe metadata (`User.unsafeMetadata`). One common use case is to collect custom information about the user during the sign-up process and store it in this property. Read more about [unsafe metadata](/docs/guides/users/extending#unsafe-metadata).
---
title: "``"
description: The component is a button that links to the sign-in
page or displays the sign-in modal.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/unstyled/sign-in-button
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/unstyled/sign-in-button.mdx
---
The `` component is a button that, by default, links to your app's sign-in page. Your sign-in page will be hosted by Clerk using the [Account Portal](/docs/guides/customizing-clerk/account-portal) unless you have set up a dedicated sign-in page.
## Usage
### Basic usage
```vue {{ filename: 'example.vue' }}
```
### Custom usage
You can create a custom button by wrapping your own button, or button text, in the `` component.
```vue {{ filename: 'example.vue' }}
```
## Properties
* `forceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs in. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `fallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `oauthFlow`
* `"redirect" | "popup" | "auto"`
Determines how OAuth authentication is performed. Accepts the following properties:
* `"redirect"`: Redirect to the OAuth provider on the current page.
* `"popup"`: Open a popup window.
* `"auto"`: Choose the best method based on whether the current domain typically requires the `"popup"` flow to correctly perform authentication.
Defaults to `"auto"`.
***
* `signUpForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs up. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpFallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `mode?`
* `'redirect' | 'modal'`
Determines what happens when a user clicks on the ``. Setting this to `'redirect'` will redirect the user to the sign-in route. Setting this to `'modal'` will open a modal on the current route. Defaults to `'redirect'`.
***
* `children?`
* `React.ReactNode`
Children you want to wrap the `` in.
***
* `initialValues`
* SignInInitialValues
The values used to prefill the sign-in fields with.
---
title: "``"
description: The `` component is a button that signs a user out.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/unstyled/sign-out-button
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: vue
sourceFile: /docs/reference/components/unstyled/sign-out-button.mdx
---
The `` component is a button that signs a user out. By default, it is a `
)}
>
Exclusive Bronze Content
This content is only visible to Bronze subscribers.
```
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Feature.
```astro {{ filename: 'src/pages/protected-premium-content.astro' }}
---
import { Protect } from '@clerk/astro/react'
---
Only subscribers with the Premium Access feature can access this content.)}
>
Exclusive Premium Content
This content is only visible to users with Premium Access feature.
```
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Permission.
```astro {{ filename: 'src/pages/protected-manage-content.astro' }}
---
import { Protect } from '@clerk/astro/react'
---
Only subscribers with the Premium Access Manage permission can access this content.
)}
>
Exclusive Management Content
This content is only visible to users with Premium Access Manage permission.
```
---
title: Clerk Billing for B2C SaaS
description: Clerk Billing is a feature that allows you to create and manage
Plans and Features for your application.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/billing/for-b2c
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: astro
sourceFile: /docs/guides/billing/for-b2c.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing for B2C SaaS allows you to create Plans and manage Subscriptions **for individual users** in your application. If you'd like to charge companies or organizations, see Billing for B2B SaaS. You can also combine both B2C and B2B Billing in the same application.
## Enable Billing
To enable Billing for your application, navigate to the [**Billing Settings**](https://dashboard.clerk.com/~/billing/settings) page in the Clerk Dashboard. This page will guide you through enabling Billing for your application.
Clerk Billing costs the same as using Stripe Billing directly, just 0.7% per transaction, plus transaction fees which are paid directly to Stripe. Clerk Billing is **not** the same as Stripe Billing. Plans and pricing are managed directly through the Clerk Dashboard and won't sync with your existing Stripe products or plans. Clerk uses Stripe **only** for payment processing, so you don't need to set up Stripe Billing.
### Payment gateway
Once you have enabled Billing, you will see the following **Payment gateway** options for collecting payments via Stripe:
* **Clerk development gateway**: A shared **test** Stripe account used for development instances. This allows developers to test and build Billing flows **in development** without needing to create and configure a Stripe account.
* **Stripe account**: Use your own Stripe account for production. **A Stripe account created for a development instance cannot be used for production**. You will need to create a separate Stripe account for your production environment.
## Create a Plan
Subscription Plans are what your users subscribe to. There is no limit to the number of Plans you can create.
To create a Plan, navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard. Here, you can create, edit, and delete Plans. To setup B2C Billing, select the **Plans for Users** tab and select **Add Plan**. When creating a Plan, you can also create Features for the Plan; see the next section for more information.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's a user Plan, it can appear in the `` component. When creating or editing a Plan, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Add Features to a Plan
[Features](/docs/guides/secure/features) make it easy to give entitlements to your Plans. You can add any number of Features to a Plan.
You can add a Feature to a Plan when you are creating a Plan. To add it after a Plan is created:
1. Navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard.
2. Select the Plan you'd like to add a Feature to.
3. In the **Features** section, select **Add Feature**.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's a user Plan, it can appear in the `` component. When adding a Feature to a Plan, it will also automatically appear in the corresponding Plan. When creating or editing a Feature, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Create a pricing page
You can create a pricing page by using the \ component. This component displays a table of Plans and Features that users can subscribe to. **It's recommended to create a dedicated page**, as shown in the following example.
```astro {{ filename: 'src/pages/pricing.astro' }}
---
import { PricingTable } from '@clerk/astro/components'
---
```
## Control access with Features and Plans
You can use Clerk's Features and Plans to gate access to the content. There are a few ways to do this, but the recommended approach is to either use the has() method or the \ component.
The `has()` method is available for any JavaScript framework, while `` is only available for React-based frameworks.
### Example: Using `has()`
Use the `has()` method to test if the user has access to a **Plan**:
```jsx
const hasPremiumAccess = has({ plan: 'gold' })
```
Or a **Feature**:
```jsx
const hasPremiumAccess = has({ feature: 'widgets' })
```
The has() method is a server-side helper that checks if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan) and returns a boolean value. `has()` is available on the auth object, which you will access differently depending on the framework you are using.
The following example demonstrates how to use `has()` to check if a user has a Plan.
```tsx {{ filename: 'src/components/bronze-content.tsx' }}
import { useAuth } from '@clerk/astro/react'
export function BronzeContent() {
const { isLoaded, has } = useAuth()
if (!isLoaded) return
Loading...
const hasBronzePlan = has({ plan: 'bronze' })
if (!hasBronzePlan) return
Only subscribers to the Bronze plan can access this content.
return
For Bronze subscribers only
}
```
```astro {{ filename: 'src/pages/content.astro' }}
---
import { BronzeContent } from '../components/bronze-content'
---
```
The following example demonstrates how to use `has()` to check if a user has a Feature.
```tsx {{ filename: 'src/components/premium-content.tsx' }}
import { useAuth } from '@clerk/astro/react'
export function PremiumContent() {
const { isLoaded, has } = useAuth()
if (!isLoaded) return
Loading...
const hasPremiumAccess = has({ feature: 'premium_access' })
if (!hasPremiumAccess)
return
Only subscribers with the Premium Access feature can access this content.
return
Our Exclusive Content
}
```
```astro {{ filename: 'src/pages/page.astro' }}
---
import { PremiumContent } from '../components/premium-content'
---
```
### Example: Using ``
The \ component protects content or even entire routes by checking if the user has been granted a specific type of access control (Role, Permission, Feature, or Plan). You can pass a `fallback` prop to `` that will be rendered if the user does not have the access control.
The following example demonstrates how to use `` to protect a page by checking if the user has a Plan.
```astro {{ filename: 'src/pages/bronze-content.astro' }}
---
import { Protect } from '@clerk/astro/react'
---
Only subscribers to the Bronze plan can access this content.)}
>
Exclusive Bronze Content
This content is only visible to Bronze subscribers.
```
The following example demonstrates how to use `` to protect a page by checking if the user has a Feature.
```astro {{ filename: 'src/pages/protected-premium-content.astro' }}
---
import { Protect } from '@clerk/astro/react'
---
Only subscribers with the Premium Access feature can access this content.)}
>
Exclusive Premium Content
This content is only visible to users with Premium Access feature.
```
---
title: Clerk Billing webhooks
description: Clerk Billing webhooks allow you to track subscription lifecycles
and monitor payment attempts.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/development/webhooks/billing
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: astro
sourceFile: /docs/guides/development/webhooks/billing.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing supports webhook events that allow you to track information like subscription lifecycles and payments.
## Subscriptions
A subscription is a top-level container unique to each user or organization. Subscription events can help you track billing changes for each of your customers.
| Event Name | Description |
| - | - |
| `subscription.created` | The top-level subscription is created. This usually happens when a user or organization is created. For existing users and organizations, a subscription will be created when Billing is enabled for the application. |
| `subscription.updated` | The top-level subscription is updated. This event is triggered when any property of the subscription has changed, except for status changes. For example, when the subscription items for the payer change. |
| `subscription.active` | The top-level subscription transitions to active from a non-active status. This happens when any subscription item is set to active, including items from the free default Plan. |
| `subscription.pastDue` | The top-level subscription contains a subscription item that has become past due. |
## Subscription items
A subscription item provides details about the relationship between the payer (user or Organization) and a Plan. A top-level subscription may contain multiple subscription items.
There can only be one `active` subscription item per payer and Plan. In addition, the subscription item for the default Plan will always have the same `id` to allow easier tracking of which users and Organizations are not paid customers.
| Event Name | Description |
| - | - |
| `subscriptionItem.updated` | The subscription item is updated. This event is triggered when a property of the subscription item has changed that does not result in a status change. For example, when a subscription item is renewed and the recurring monthly charge succeeds, the status doesn't change (remains `active`), but `period_start` and `period_end` are updated. This results in a `subscriptionItem.updated` event. |
| `subscriptionItem.active` | The subscription item is set to active. For paid Plans, this happens on successful payment. |
| `subscriptionItem.canceled` | The subscription item is canceled. The payer retains Plan features until the end of the current billing period. |
| `subscriptionItem.upcoming` | The subscription item is set as upcoming after the current billing period. This can happen in the case of a deferred Plan change from a higher-priced to lower-priced Plan. In the case a paid Plan is canceled, the subscription item for the default, free Plan will be set as `upcoming`. |
| `subscriptionItem.ended` | The subscription item has ended. |
| `subscriptionItem.abandoned` | The subscription item is abandoned. This can happen to `upcoming` subscription items if the payer subscribes to another Plan, or re-subscribes to a currently canceled Plan. |
| `subscriptionItem.incomplete` | The subscription item is incomplete. This means the payer has started a checkout for a Plan, but the payment hasn't been successfully processed yet. Once payment succeeds, the subscription item transitions to an `active` status. |
| `subscriptionItem.pastDue` | The subscription item is past due because a recurring charge has failed. |
| `subscriptionItem.freeTrialEnding` | The subscription item is a free trial and is ending soon. This event is sent three days before the trial ends. If the trial is shorter than three days, it's sent immediately. |
## Payment attempts
Payment attempts allow you to track successful and failed payments, for both checkout and recurring charges.
Payment attempt events contain a `type`, which can be either `checkout` or `recurring`. You can use these values to determine whether a payment attempt was for a checkout or a subscription item renewal's recurring charge.
| Event Name | Description |
| - | - |
| `paymentAttempt.created` | A payment attempt has been created with `pending` status. It can either succeed or fail in the future. |
| `paymentAttempt.updated` | A payment attempt has been updated to `paid` or `failed` status. |
Looking for other webhook events? To find a list of all the events Clerk supports, navigate to the [**Webhooks**](https://dashboard.clerk.com/~/webhooks) page and select the **Event Catalog** tab.
---
title: Protect content and read user data
description: Learn how to use Clerk's helpers to protect content and read user
data in your Astro application.
metadata:
title: Read session and user data in your Astro app with Clerk
sdk: nextjs, expo, react-router, remix, tanstack-react-start, astro, nuxt
sdkScoped: "true"
canonical: /docs/:sdk:/guides/users/reading
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,expo,react-router,remix,tanstack-react-start,astro,nuxt
notAvailableSdks: react,js-frontend,chrome-extension,android,ios,expressjs,fastify,go,vue,ruby,js-backend
activeSdk: astro
sourceFile: /docs/guides/users/reading.astro.mdx
---
Clerk provides helpers that you can use to protect content and read user data in your Astro application.
## Server-side
The [`auth()`](/docs/reference/astro/locals) and [`currentUser()`](/docs/reference/astro/locals) locals are Astro-specific helpers that you can use inside of your Astro components and [endpoints](https://docs.astro.build/en/guides/endpoints/#server-endpoints-api-routes).
* The `auth()` local returns the Auth object of the currently active user.
* The `currentUser()` local returns the Backend User object of the currently active user. This is helpful if you want to render user information, like their first and last name, directly from the server. Under the hood, `currentUser()` uses the clerkClient wrapper to make a call to the Backend API. **This does count towards the [Backend API request rate limit](/docs/guides/how-clerk-works/system-limits)**. This also uses `fetch()` so it is automatically deduped per request.
The following example demonstrates how to protect a page from unauthenticated users and access the current user's information.
```astro {{ filename: 'src/pages/me.astro' }}
---
// Use `locals.auth()` to access `isAuthenticated` and the user's ID
const { isAuthenticated, userId } = Astro.locals.auth()
// Protect the route by checking if the user is signed in
if (!isAuthenticated) {
return Astro.redirect('/login')
}
// Get the Backend User object when you need access to the user's information
const user = await Astro.locals.currentUser()
---
Welcome, {user.firstName}!
```
```tsx {{ filename: 'src/api/me.ts' }}
export async function GET({ locals }) {
// Use `locals.auth()` to access `isAuthenticated` and the user's ID
const { isAuthenticated, userId } = locals.auth()
// Protect the route by checking if the user is signed in
if (!isAuthenticated) {
return new Response('Unauthorized', { status: 401 })
}
// Get the Backend User object when you need access to the user's information
const user = await locals.currentUser()
// Add your Route Handler's logic with the returned `user` object
return new Response(
JSON.stringify({ userId: user.id, email: user.emailAddresses[0].emailAddress }),
)
}
```
### Retrieve data from external sources
Clerk provides integrations with a number of popular databases.
To retrieve a token from a [JWT template](/docs/guides/sessions/jwt-templates) and fetch data from an external source, use the getToken(){{ target: '_blank' }} method from the `auth()` local.
```ts {{ filename: 'src/pages/api/route.ts' }}
export async function GET({ locals }) {
// Use `locals.auth()` to access `isAuthenticated`, the user's ID, and the `getToken()` method
const { isAuthenticated, userId, getToken } = locals.auth()
// Protect the route by checking if the user is signed in
if (!isAuthenticated) {
return new Response('Unauthorized', { status: 401 })
}
// Use `getToken()` to get a token from the JWT template
const token = await getToken({ template: 'supabase' })
// Fetch data from Supabase and return it
const data = { supabaseData: 'Hello World' }
return new Response(JSON.stringify(data))
}
```
## Client-side
Clerk Astro provides a set of useful [stores](/docs/reference/astro/overview#client-side-helpers) that give you access to many important objects, such as the `Clerk`, `User`, and `Session` object.
### `$authStore`
The following example demonstrates how to use the [`$authStore`](/docs/reference/astro/client-side-helpers/auth-store) to access the current auth state. It uses `userId` to detect if the user is signed in.
```tsx {{ filename: 'components/external-data.tsx' }}
import { useStore } from '@nanostores/react'
import { $authStore } from '@clerk/astro/client'
export default function ExternalData() {
const { userId } = useStore($authStore)
if (userId === undefined) {
// Handle loading state however you like
return
Loading...
}
if (userId === null) {
// Handle signed out state however you like
return
{/if}
```
### `$userStore`
The following example demonstrates how to use the [`$userStore`](/docs/reference/astro/client-side-helpers/user-store) to access the `User` object. It returns `undefined` while Clerk is still loading and `null` if the user is not signed in.
For more information, see the User reference{{ target: '_blank' }}.
```tsx {{ filename: 'user.tsx' }}
import { useStore } from '@nanostores/react'
import { $userStore } from '@clerk/astro/client'
export default function User() {
const user = useStore($userStore)
if (user === undefined) {
// Handle loading state however you like
return null
}
if (user === null) {
return
{/if}
```
---
title: Component Reference
description: A list of Clerk's comprehensive suite of components designed to
seamlessly integrate authentication and multi-tenancy into your application.
sdk: react, nextjs, js-frontend, chrome-extension, expo, android, expressjs,
fastify, react-router, remix, tanstack-react-start, go, astro, nuxt, vue,
ruby, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/overview
lastUpdated: 2025-11-21T23:29:30.000Z
availableSdks: react,nextjs,js-frontend,chrome-extension,expo,android,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
notAvailableSdks: ios
activeSdk: astro
sourceFile: /docs/reference/components/overview.mdx
---
Clerk offers a comprehensive suite of components designed to seamlessly integrate authentication and multi-tenancy into your application. With Clerk components, you can easily customize the appearance of authentication components and pages, manage the entire authentication flow to suit your specific needs, and even build robust SaaS applications.
## Authentication components
* \
* \
* \
* \
* \
## User components
* \
* \
* \
## Organization components
* \
* \
* \
* \
## Billing components
* \
* \
* \
* \
## Control components
Control components manage authentication-related behaviors in your application. They handle tasks such as controlling content visibility based on user authentication status, managing loading states during authentication processes, and redirecting users to appropriate pages. Control components render at `` and `` states for assertions on the Clerk object. A common example is the \ component, which allows you to conditionally render content only when a user is authenticated.
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
## Unstyled components
* \
* \
* \
* \
## Customization guides
* [Customize components with the `appearance` prop](/docs/guides/customizing-clerk/appearance-prop/overview)
* [Localize components with the `localization` prop (experimental)](/docs/guides/customizing-clerk/localization)
* [Add pages to the `` component](/docs/guides/customizing-clerk/adding-items/user-profile)
* [Add pages to the `` component](/docs/guides/customizing-clerk/adding-items/organization-profile)
### Secured by Clerk branding
> \[!WARNING]
> This feature requires a [paid plan](/pricing){{ target: '_blank' }} for production use, but all features are free to use in development mode so that you can try out what works for you. See the [pricing](/pricing){{ target: '_blank' }} page for more information.
By default, Clerk displays a **Secured by Clerk** badge on Clerk components. You can remove this branding by following these steps:
1. In the Clerk Dashboard, navigate to your application's [**Settings**](https://dashboard.clerk.com/~/settings).
2. Under **Branding**, toggle on the **Remove "Secured by Clerk" branding** option.
* [Join our Discord](https://clerk.com/discord "Join Discord")
* Join our official Discord server to chat with us directly and become a part of the Clerk community.
* {}
***
* [Need help?](/support "Get help")
* Contact us through Discord, Twitter, or email to receive answers to your questions and learn more about Clerk.
* {}
---
title: "`` component"
description: Clerk's component renders a UI for authenticating
users with Google's One Tap API.
sdk: astro, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/authentication/google-one-tap
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: chrome-extension,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: astro
sourceFile: /docs/reference/components/authentication/google-one-tap.mdx
---
> \[!IMPORTANT]
> To use Google One Tap with Clerk, you must [enable Google as a social connection in the Clerk Dashboard](/docs/guides/configure/auth-strategies/social-connections/google#configure-for-your-production-instance) and make sure to use custom credentials.
The `` component renders the [Google One Tap](https://developers.google.com/identity/gsi/web/guides/features) UI so that users can use a single button to sign-up or sign-in to your Clerk application with their Google accounts.
By default, this component will redirect users back to the page where the authentication flow started. However, you can override this with force redirect URL props or [force redirect URL environment variables](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects).
> \[!TIP]
> `` does not render if the user is already signed into your Clerk application, so there's no need to manually check if a user is signed in yourself before rendering it.
## Example
The following example includes basic implementation of the `` component. You can use this as a starting point for your own implementation.
```astro {{ filename: 'pages/sign-in.astro' }}
---
import { GoogleOneTap } from '@clerk/astro/components'
---
```
## Properties
* `cancelOnTapOutside?`
* `boolean`
If `true`, the One Tap prompt closes automatically if the user clicks outside of the prompt. Defaults to `true`.
***
* `itpSupport?`
* `boolean`
If `true`, enables the [ITP-specific UX](https://developers.google.com/identity/gsi/web/guides/itp) when One Tap is rendered on ITP browsers such as Chrome on iOS, Safari, and FireFox. Defaults to `true`.
***
* `fedCmSupport?`
* `boolean`
If `true`, enables Google One Tap to use [the FedCM API](https://developers.google.com/privacy-sandbox/3pcd/fedcm) to sign users in. See Google's docs on [best practices when disabling FedCM support](https://developers.google.com/identity/gsi/web/guides/display-google-one-tap#do_not_cover_google_one_tap). Defaults to `true`
***
* `signInForceRedirectUrl?`
* `string`
Useful if you want to redirect to a path specific to Google One Tap users. If provided, this URL will **always** be redirected to after the user signs in, overriding any \ redirect URL props or [redirect URL environment variables](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects).
***
* `signUpForceRedirectUrl?`
* `string`
Useful if you want to redirect to a path specific to Google One Tap users. If provided, this URL will **always** be redirected to after the user signs up, overriding any \ redirect URL props or [redirect URL environment variables](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects).
## Limitations
* If your application will use the Google API on behalf of your users, the `` component is not recommended, as Google does not provide Clerk with an access or refresh token that you can use.
* Users with the 1Password browser extension may not be able to render the Google One Tap UI. They must disable this extension.
* When testing in development, if you select the `X` button to close the Google One Tap UI, you may encounter [a cooldown](https://developers.google.com/identity/gsi/web/guides/features#exponential_cooldown) that prevents you from rendering it again for a period of time. To bypass the cooldown, remove the `g_state` cookie.
---
title: "`` component"
description: Clerk's component renders a UI for signing up users.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/authentication/sign-up
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: astro
sourceFile: /docs/reference/components/authentication/sign-up.mdx
---
{{ style: { maxWidth: '460px' } }}
The `` component renders a UI for signing up users. The functionality of the `` component is controlled by the instance settings you specify in the [Clerk Dashboard](https://dashboard.clerk.com), such as [sign-in and sign-up options](/docs/guides/configure/auth-strategies/sign-up-sign-in-options) and [social connections](/docs/guides/configure/auth-strategies/social-connections/all-providers). You can further customize your `` component by passing additional properties at the time of rendering.
> \[!NOTE]
> The `` and `` components cannot render when a user is already signed in, unless the application allows multiple sessions. If a user is already signed in and the application only allows a single session, Clerk will redirect the user to the Home URL instead.
## Example
The following example includes basic implementation of the `` component. You can use this as a starting point for your own implementation.
```astro {{ filename: 'pages/signup.astro' }}
---
import { SignUp } from '@clerk/astro/components'
---
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `fallbackRedirectUrl`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `forceRedirectUrl`
* `string`
If provided, this URL will always be used as the redirect destination after the user signs up. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `initialValues`
* SignUpInitialValues
The values used to prefill the sign-up fields with.
***
* `oauthFlow`
* `"redirect" | "popup" | "auto"`
Determines how OAuth authentication is performed. Accepts the following properties:
* `"redirect"`: Redirect to the OAuth provider on the current page.
* `"popup"`: Open a popup window.
* `"auto"`: Choose the best method based on whether the current domain typically requires the `"popup"` flow to correctly perform authentication.
Defaults to `"auto"`.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash-based routing. For example: `/sign-up`.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
***
* `signInFallbackRedirectUrl`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Used for the 'Already have an account? Sign in' link that's rendered. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signInForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs in. Used for the 'Already have an account? Sign in' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signInUrl`
* `string`
The full URL or path to the sign-in page. Used for the 'Already have an account? Sign in' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `unsafeMetadata`
* SignUpUnsafeMetadata
Metadata that can be read and set from the frontend and the backend. Once the sign-up is complete, the value of this field will be automatically copied to the created user's unsafe metadata (`User.unsafeMetadata`). One common use case is to collect custom information about the user during the sign-up process and store it in this property. Read more about [unsafe metadata](/docs/guides/users/extending#unsafe-metadata).
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
If Clerk's prebuilt components don't meet your specific needs or if you require more control over the logic, you can rebuild the existing Clerk flows using the Clerk API. For more information, see the [custom flow guides](/docs/guides/development/custom-flows/overview).
---
title: "`` component"
description: The component renders a waitlist form that allows
users to join for early access to your application.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/authentication/waitlist
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: astro
sourceFile: /docs/reference/components/authentication/waitlist.mdx
---
{{ style: { maxWidth: '460px' } }}
In **Waitlist** mode, users can register their interest in your app by joining a waitlist. This mode is ideal for apps in early development stages or those wanting to generate interest before launch. [Learn more about additional features available in **Waitlist** mode](/docs/guides/secure/restricting-access#waitlist).
The `` component renders a form that allows users to join for early access to your app.
## Enable Waitlist mode
Before using the `` component, you must enable **Waitlist** mode in the Clerk Dashboard:
1. In the Clerk Dashboard, navigate to the [**Restrictions**](https://dashboard.clerk.com/~/user-authentication/restrictions) page.
2. Under the **Sign-up modes** section, enable **Waitlist**.
## Example
> \[!WARNING]
> Before using the `` component, you must provide the `waitlistUrl` prop either in the \ or \ component to ensure proper functionality.
The following example includes a basic implementation of the `` component. You can use this as a starting point for your own implementation.
```astro {{ filename: 'pages/waitlist.astro' }}
---
import { Waitlist as WaitlistAstro } from '@clerk/astro/components'
---
```
## Properties
All props are optional.
* `afterJoinWaitlistUrl`
* `string`
The full URL or path to navigate to after joining the waitlist.
***
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `signInUrl`
* `string`
The full URL or path to the sign in page. Used for the 'Already have an account? Sign in' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
## Customization
To learn about how to customize Clerk components, see the [customization guide](/docs/guides/customizing-clerk/appearance-prop/overview).
---
title: "`` component"
description: Clerk's component renders a UI for signing in users.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/authentication/sign-in
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: astro
sourceFile: /docs/reference/components/authentication/sign-in.mdx
---
{{ style: { maxWidth: '460px' } }}
The `` component renders a UI to allow users to sign in or sign up by default. The functionality of the `` component is controlled by the instance settings you specify in the [Clerk Dashboard](https://dashboard.clerk.com), such as [sign-in and sign-up options](/docs/guides/configure/auth-strategies/sign-up-sign-in-options) and [social connections](/docs/guides/configure/auth-strategies/social-connections/all-providers). You can further customize your `` component by passing additional properties at the time of rendering.
> \[!NOTE]
> The `` and `` components cannot render when a user is already signed in, unless the application allows multiple sessions. If a user is already signed in and the application only allows a single session, Clerk will redirect the user to the Home URL instead.
## Example
The following example includes basic implementation of the `` component. You can use this as a starting point for your own implementation.
```astro {{ filename: 'pages/signin.astro' }}
---
import { SignIn } from '@clerk/astro/components'
---
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `fallbackRedirectUrl`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `forceRedirectUrl`
* `string`
If provided, this URL will always be redirected to after the user signs in. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `initialValues`
* SignInInitialValues
The values used to prefill the sign-in fields with.
***
* `oauthFlow`
* `"redirect" | "popup" | "auto"`
Determines how OAuth authentication is performed. Accepts the following properties:
* `"redirect"`: Redirect to the OAuth provider on the current page.
* `"popup"`: Open a popup window.
* `"auto"`: Choose the best method based on whether the current domain typically requires the `"popup"` flow to correctly perform authentication.
Defaults to `"auto"`.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash-based routing. For example: `/sign-in`.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
***
* `signUpFallbackRedirectUrl`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Used for the 'Don't have an account? Sign up' link that's rendered. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpForceRedirectUrl`
* `string`
If provided, this URL will always used as the redirect destination after the user signs up. Used for the 'Don't have an account? Sign up' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpUrl`
* `string`
The full URL or path to the sign-up page. Used for the 'Don't have an account? Sign up' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `transferable`
* `boolean`
Indicates whether or not sign in attempts are transferable to the sign up flow. Defaults to `true`. When set to `false`, prevents opaque sign ups when a user attempts to sign in via OAuth with an email that doesn't exist.
***
* `waitlistUrl`
* `string`
Full URL or path to the waitlist page. Use this property to provide the target of the 'Waitlist' link that's rendered. If `undefined`, will redirect to the [Account Portal waitlist page](/docs/guides/customizing-clerk/account-portal#waitlist). If you've passed the `waitlistUrl` prop to the \ component, it will infer from that, and you can omit this prop.
***
* `withSignUp`
* `boolean`
Opt into sign-in-or-up flow by setting this prop to `true`. When `true`, if a user does not exist, they will be prompted to sign up. If a user exists, they will be prompted to sign in. Defaults to `true` if the `CLERK_SIGN_IN_URL` environment variable is set. Otherwise, defaults to `false`.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
If Clerk's prebuilt components don't meet your specific needs or if you require more control over the logic, you can rebuild the existing Clerk flows using the Clerk API. For more information, see the [custom flow guides](/docs/guides/development/custom-flows/overview).
---
title: "``"
description: Clerk's component displays a table of Plans and
Features that users can subscribe to.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/billing/pricing-table
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: astro
sourceFile: /docs/reference/components/billing/pricing-table.mdx
---

The `` component displays a table of Plans and Features that users can subscribe to.
## Example
The following example includes a basic implementation of the `` component. You can use this as a starting point for your own implementation.
```astro {{ filename: 'pages/pricing.astro' }}
---
import { PricingTable } from '@clerk/astro/components'
---
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `checkoutProps`
* `{ appearance: Appearance }`
Options for the checkout drawer. Accepts the following properties:
* [`appearance`](/docs/guides/customizing-clerk/appearance-prop/overview): an object used to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `collapseFeatures`
* `boolean`
A boolean that indicates whether the Features are collapsed. **Requires `layout` to be set to `'default'`**. Defaults to `false`.
***
* `ctaPosition`
* `'top' | 'bottom'`
The placement of the CTA button. **Requires `layout` to be set to `'default'`**. Defaults to `'bottom'`.
***
* `fallback`
* `JSX`
An optional UI to show when the pricing table is loading.
***
* `for`
* `'user' | 'organization'`
A string that indicates whether the pricing table is for users or [Organizations](/docs/guides/organizations/overview). If `'user'`, the pricing table will display a list of Plans and Features that **users** can subscribe to. If `'organization'`, the pricing table will display a list of Plans and Features that **Organizations** can subscribe to. Defaults to `'user'`.
***
* `newSubscriptionRedirectUrl`
* `string`
The URL to navigate to after the user completes the checkout and selects the "Continue" button.
---
title: "``"
description: The `` component guarantees that the Clerk object has
loaded and will be available under `window.Clerk`. This allows you to wrap
child components to access the Clerk object without the need to check it
exists.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/clerk-loaded
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: astro
sourceFile: /docs/reference/components/control/clerk-loaded.mdx
---
The `` component guarantees that the Clerk object has loaded (the `status` is `'ready'` or `'degraded'`) and will be available under `window.Clerk`. This allows you to wrap child components to access the `Clerk` object without the need to check it exists.
## Example
It's not recommended to wrap the entire app in the `` component; instead, only wrap the components that need access to the `Clerk` object.
> \[!NOTE]
> Unlike other Clerk components for Astro, `` must be imported from `@clerk/astro/react`. This requires that your Astro app is set up with React. See [Use Clerk with Astro and React](/docs/reference/astro/react) for guidance.
```astro {{ filename: 'index.astro' }}
---
import { ClerkLoaded } from '@clerk/astro/react'
---
Clerk has loaded
```
---
title: \RedirectCallback />
description: Clerk's `` component is used to
implement custom OAuth flows. It handles the OAuth callback and completes the
authentication process.
sdk: astro, chrome-extension, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/authenticate-with-redirect-callback
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: expo,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: astro
sourceFile: /docs/reference/components/control/authenticate-with-redirect-callback.mdx
---
The `` component is a crucial part of implementing custom OAuth flows in your application. It serves as the callback handler for the authentication process initiated by the `authenticateWithRedirect()` method. Render it on the route specified as the `redirectUrl` in your `authenticateWithRedirect()` call.
This component automatically handles the OAuth callback, completing the authentication process and managing the user's session. It uses the handleRedirectCallback() method under the hood.
## Example
For an example of how to use the `` component, see the [custom flow](/docs/guides/development/custom-flows/authentication/oauth-connections) guide.
## Properties
All props are optional.
* `continueSignUpUrl?`
* `string | undefined | null`
The full URL or path to navigate to if the sign up requires additional information.
***
* `signInUrl?`
* `string`
The full URL or path where the `` component is mounted.
***
* `signUpUrl?`
* `string`
The full URL or path where the `` component is mounted.
***
* `signInFallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpFallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signInForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs in. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs up. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `firstFactorUrl?`
* `string | undefined`
The full URL or path to navigate to during sign in, if first factor verification is required.
***
* `secondFactorUrl?`
* `string | undefined`
The full URL or path to navigate to during sign in, if [multi-factor authentication](/docs/guides/configure/auth-strategies/sign-up-sign-in-options#multi-factor-authentication) is enabled.
***
* `resetPasswordUrl?`
* `string`
The full URL or path to navigate to during sign in, if the user is required to reset their password.
***
* `transferable?`
* `boolean`
A boolean that indicates whether or not sign in attempts are transferable to the sign up flow. Defaults to `true`. When set to `false`, prevents opaque sign ups when a user attempts to sign in via OAuth with an email that doesn't exist.
***
* `verifyEmailAddressUrl?`
* `string | undefined | null`
The full URL or path to navigate to after requesting email verification.
***
* `verifyPhoneNumberUrl?`
* `string | undefined | null`
The full URL or path to navigate to after requesting phone verification.
---
title: "``"
description: The `` renders its children while Clerk is loading,
and is helpful for showing a custom loading state.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/clerk-loading
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: astro
sourceFile: /docs/reference/components/control/clerk-loading.mdx
---
The `` renders its children while Clerk is loading, and is helpful for showing a custom loading state.
## Example
It's not recommended to wrap the entire app in the `` component; instead, only wrap the components that need access to the `Clerk` object.
> \[!NOTE]
> Unlike other Clerk components for Astro, `ClerkLoading` must be imported from `@clerk/astro/react`. This requires that your Astro app is set up with React. See [Use Clerk with Astro and React](/docs/reference/astro/react) for guidance.
```astro {{ filename: 'index.astro' }}
---
import { ClerkLoading, ClerkLoaded } from '@clerk/astro/react'
---
Clerk is loading
Clerk has loaded
```
---
title: "``"
description: The Protect component protects content or even entire routes based
on authentication, and optionally, authorization. It only renders its children
when the current user is signed-in, and if performing authorization checks, if
the user has been granted a specific type of access control (Role, Permission,
Feature, or Plan).
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/protect
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: astro
sourceFile: /docs/reference/components/control/protect.mdx
---
The \ component protects content or even entire routes based on:
* authentication: whether the user is signed-in or not.
* authorization: whether the user has been granted a specific type of access control (Role, Permission, Feature, or Plan)
`` **always** performs authentication checks. To perform authorization checksAuthorization checks are checks you perform in your code to determine the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions or access certain content. Learn more about [authorization checks](/docs/guides/secure/authorization-checks)., you can pass different props, like `role`, `permission`, `feature`, or `plan`.
`` accepts a `fallback` prop that will be rendered if the user fails the authentication or authorization checks.
`` can be used both client-side and server-side (in Server Components).
> \[!CAUTION]
> This component only **visually hides** its children when the current user is not authorized. The contents of its children remain accessible via the browser's source code even if the user fails the authorization check. Do not use this component to hide sensitive information that should be completely inaccessible to unauthorized users. For truly sensitive data, perform authorization checksAuthorization checks are checks you perform in your code to determine the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions or access certain content. Learn more about [authorization checks](/docs/guides/secure/authorization-checks). on the server before sending the data to the client.
## Usage
### Authentication checks
`` always performs authentication checks. It will render its children if the user is signed-in, and its `fallback` prop if the user is signed-out.
```astro {{ filename: 'src/pages/dashboard.astro' }}
---
import { Protect } from '@clerk/astro/components'
---
Users that are signed-out can see this.
Users that are signed-in can see this.
```
### Authorization checks
To limit who is able to see the content that `` renders, you can pass **one** of the access control props: `permission`, `role`, `feature`, or `plan`. It's recommended to use **Permission-based** authorization over **Role-based** authorization, and **Feature-based** authorization over **Plan-based** authorization, as they are more flexible, easier to manage, and more secure.
If you do not pass any of the access control props, `` will render its children if the user is signed in, regardless of their Role or its Permissions.
For more complex authorization logic, pass conditional logic to the `condition` prop.
### Render content by Permissions
The following example demonstrates how to use the `` component to protect content by checking if the user has the `org:invoices:create` Permission.
```astro {{ filename: 'src/pages/invoices.astro' }}
---
import { Protect } from '@clerk/astro/components'
---
You do not have the Permissions to create an invoice.
Users with Permission org:invoices:create can see this.
```
### Render content by Role
While authorization by `permission` is **recommended**, for convenience, `` allows a `role` prop to be passed.
The following example demonstrates how to use the `` component to protect content by checking if the user has the `org:billing` Role.
```astro {{ filename: 'src/pages/billing.astro' }}
---
import { Protect } from '@clerk/astro/components'
---
Only a member of the Billing department can access this content.
Users with Role org:billing can see this.
```
### Render content by Plan
The following example demonstrates how to use `` to protect content by checking if the user has a Plan.
```astro {{ filename: 'src/pages/bronze.astro' }}
---
import { Protect } from '@clerk/astro/components'
---
Sorry, only subscribers to the Bronze plan can access this content.
Welcome, Bronze subscriber!
```
### Render content by Feature
The following example demonstrates how to use `` to protect content by checking if the user has a Feature.
```astro {{ filename: 'src/pages/premium-access.astro' }}
---
import { Protect } from '@clerk/astro/components'
---
Sorry, only subscribers with the Premium Access feature can access this content.
Congratulations! You have access to the Premium Access feature.
```
### Render content conditionally
The following example uses ``'s `condition` prop to conditionally render its children if the user has the correct Role.
```astro
---
import { Protect } from '@clerk/astro/components'
---
has({ role: 'org:admin' }) || has({ role: 'org:billing_manager' })}>
Only an Admin or Billing Manager can access this content.
The settings page.
```
## Properties
* `condition?`
* `has => boolean`
Optional conditional logic that renders the children if it returns `true`.
***
* `fallback?`
* `JSX`
Optional UI to show when a user doesn't have the correct type of access control to access the protected content.
***
* `feature?`
* `string`
Optional string corresponding to a [Feature](/docs/guides/billing/overview).
***
* `plan?`
* `string`
Optional string corresponding to a [Plan](/docs/guides/billing/overview).
***
* `permission?`
* `string`
Optional string corresponding to a [Permission](/docs/guides/organizations/roles-and-permissions) in the format `org::`
***
* `role?`
* `string`
Optional string corresponding to a [Role](/docs/guides/organizations/roles-and-permissions) in the format `org:`
***
* `treatPendingAsSignedOut?`
* `boolean`
A boolean that indicates whether to treat pending sessions as signed out. Defaults to `true`.
---
title: "``"
description: Conditionally render content only when a user is signed out.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/signed-out
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: astro
sourceFile: /docs/reference/components/control/signed-out.mdx
---
The `` component offers authentication checks as a cross-cutting concern. Any child nodes wrapped by a `` component will be rendered only if there's no User signed in to your application.
## Example
```astro {{ filename: 'index.astro' }}
---
import { SignedOut } from '@clerk/astro/components'
---
You are signed out.
This content is always visible.
```
## Properties
* `treatPendingAsSignedOut?`
* `boolean`
A boolean that indicates whether to treat pending sessions as signed out. Defaults to `true`.
---
title: "``"
description: Conditionally render content only when a user is signed in.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/signed-in
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: astro
sourceFile: /docs/reference/components/control/signed-in.mdx
---
## Overview
The `` component offers authentication checks as a cross-cutting concern. Any children components wrapped by a `` component will be rendered only if there's a user with an active session signed in your application.
> \[!CAUTION]
> This component only **visually hides** its children when the current user is not authenticated. The contents of its children remain accessible via the browser's source code even if the user fails the authentication check. Do not use this component to hide sensitive information that should be completely inaccessible to unauthorized users. For truly sensitive data, perform authorization checksAuthorization checks are checks you perform in your code to determine the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions or access certain content. Learn more about [authorization checks](/docs/guides/secure/authorization-checks). on the server before sending the data to the client.
## Example
```astro {{ filename: 'index.astro' }}
---
import { SignedIn } from '@clerk/astro/components'
---
You are signed in.
This content is always visible.
```
## Properties
* `treatPendingAsSignedOut?`
* `boolean`
A boolean that indicates whether to treat pending sessions as signed out. Defaults to `true`.
---
title: "`` component"
description: Clerk's component is used to render an
Organization creation UI that allows users to create brand new Organizations
within your application.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/organization/create-organization
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: astro
sourceFile: /docs/reference/components/organization/create-organization.mdx
---
{{ style: { maxWidth: '492px' } }}
The `` component is used to render an Organization creation UI that allows users to create brand new Organizations in your application.
## Example
The following example includes a basic implementation of the `` component. You can use this as a starting point for your own implementation.
```astro {{ filename: '/pages/create-organization.astro' }}
---
import { CreateOrganization } from '@clerk/astro/components'
---
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `afterCreateOrganizationUrl`
* `string`
Full URL or path to navigate to after creating a new organization.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash-based routing. For example: `/create-organization`.
***
* `skipInvitationScreen`
* `boolean`
Hides the screen for sending invitations after an Organization is created. When left undefined, Clerk will automatically hide the screen if the number of max allowed members is equal to 1
***
* `hideSlug`
* `boolean`
Hides the optional slug field in the Organization creation screen.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
---
title: "`` component"
description: Clerk's component is used to display
Organization related memberships, invitations, and suggestions for the user.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/organization/organization-list
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: astro
sourceFile: /docs/reference/components/organization/organization-list.mdx
---
{{ style: { maxWidth: '460px' } }}
The `` component displays Organization-related memberships and automatic [invitations](/docs/guides/organizations/verified-domains#automatic-invitations) and [suggestions](/docs/guides/organizations/verified-domains#automatic-suggestions) for the user.
## Example
```astro {{ filename: '/pages/organizations.astro' }}
---
import { OrganizationList } from '@clerk/astro/components'
---
```
## Properties
The `` component accepts the following properties, all of which are **optional**:
* `afterCreateOrganizationUrl`
* ((org: Organization) => string) | string
The full URL or path to navigate to after creating a new Organization.
***
* `afterSelectOrganizationUrl`
* ((org: Organization) => string) | string
The full URL or path to navigate to after selecting an Organization. Defaults to `undefined`.
***
* `afterSelectPersonalUrl`
* ((org: Organization) => string) | string
The full URL or path to navigate to after selecting the [Personal Account](/docs/guides/organizations/overview#allow-personal-accounts). Defaults to `undefined`.
***
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `hidePersonal`
* `boolean`
A boolean that controls whether `` will include the user's [Personal Account](/docs/guides/organizations/overview#allow-personal-accounts) in the Organization list. Setting this to `true` will hide the Personal Account option, and users will only be able to switch between Organizations. Defaults to `false`.
***
* `hideSlug`
* `boolean`
A boolean that controls whether the optional slug field in the Organization creation screen is hidden. Defaults to `false`.
***
* `skipInvitationScreen`
* `boolean | undefined`
A boolean that controls whether the screen for sending invitations after an Organization is created is hidden. When `undefined`, Clerk will automatically hide the screen if the number of max allowed members is equal to 1. Defaults to `false`.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
[org-ref]: /docs/reference/javascript/organization
---
title: "`` component"
description: Clerk's component is used to enable the
ability to switch between available Organizations the user may be part of in
your application.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/organization/organization-switcher
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: astro
sourceFile: /docs/reference/components/organization/organization-switcher.mdx
---
{{ style: { maxWidth: '436px' } }}
The `` component allows a user to switch between their joined Organizations. If [Personal Accounts are enabled](/docs/guides/organizations/overview#allow-personal-accounts), users can also switch to their Personal Account. This component is useful for applications that have a multi-tenant architecture, where users can be part of multiple Organizations. It handles all Organization-related flows, including full Organization management for admins. Learn more about [Organizations](/docs/guides/organizations/overview).
## Example
```astro {{ filename: '/pages/organization-switcher.astro' }}
---
import { OrganizationSwitcher } from '@clerk/astro/components'
---
```
## Properties
The `` component accepts the following properties, all of which are **optional**:
* `afterCreateOrganizationUrl`
* `string`
The full URL or path to navigate to after creating a new Organization.
***
* `afterLeaveOrganizationUrl`
* `string`
The full URL or path to navigate to after the user leaves the currently Active OrganizationA user can be a member of multiple Organizations, but only one can be active at a time. The **Active Organization** determines which Organization-specific data the user can access and which Role and related Permissions they have within the Organization..
***
* `afterSelectOrganizationUrl`
* `string`
The full URL or path to navigate to after a successful Organization switch.
***
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `createOrganizationMode`
* `'modal' | 'navigation'`
A boolean that controls whether clicking the "Create organization" button will cause the \ component to open as a modal, or if the browser will navigate to the `createOrganizationUrl` where `` is mounted as a page. Defaults to: `'modal'`.
***
* `createOrganizationUrl`
* `string`
The full URL or path where the ``]createorg-ref component is mounted.
***
* `defaultOpen`
* `boolean`
A boolean that controls the default state of the `` component.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `hidePersonal`
* `boolean`
A boolean that controls whether `` will include the user's [Personal Account](/docs/guides/organizations/overview#allow-personal-accounts) in the Organization list. Setting this to `true` will hide the Personal Account option, and users will only be able to switch between Organizations. Defaults to `false`.
***
* `hideSlug`
* `boolean`
A boolean that controls whether the optional slug field in the Organization creation screen is hidden.
***
* `organizationProfileMode`
* `'modal' | 'navigation'`
A boolean that controls whether clicking the **Manage organization** button will cause the \ component to open as a modal, or if the browser will navigate to the `organizationProfileUrl` where `` is mounted as a page. Defaults to: `'modal'`.
***
* `organizationProfileProps`
* `object`
Specify options for the underlying \ component. For example: `{appearance: {...}}`
***
* `organizationProfileUrl`
* `string`
The full URL or path where the \ component is mounted.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
[createorg-ref]: /docs/reference/components/organization/create-organization
[orgprofile-ref]: /docs/reference/components/organization/organization-profile
---
title: "`` component"
description: Clerk's component is used to render a
beautiful, full-featured Organization management UI that allows users to
manage their Organization profile and security settings.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/organization/organization-profile
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: astro
sourceFile: /docs/reference/components/organization/organization-profile.mdx
---

The `` component allows users to manage their Organization membership, security, and billing settings.
This component's **General** tab displays the Organization's information and the **Leave organization** button. Admins will be able to see the **Update profile** button, **Verified domains** section, and **Delete organization** button.
The **Members** tab shows the Organization's members along with their join dates and Roles. Admins will have the ability to invite a member, change a member's Role, or remove them from the Organization. Admins will have tabs within the **Members** tab to view the Organization's [invitations](/docs/guides/organizations/overview#organization-invitations) and [requests](/docs/guides/organizations/verified-domains#membership-requests).
The **Billing** tab displays the Plans and Features that are available to the Organization, as well as the user's billing information, such as their invoices and payment methods.
## Example
```astro {{ filename: '/pages/organization-profile.astro' }}
---
import { OrganizationProfile } from '@clerk/astro/components'
---
```
## Properties
The `` component accepts the following properties, all of which are **optional**:
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `afterLeaveOrganizationUrl`
* `string`
The full URL or path to navigate to after leaving an Organization.
***
* `customPages`
* `CustomPages[]`
An array of custom pages to add to the Organization profile. Only available for the JavaScript SDK. To add custom pages with React-based SDK's, see the [dedicated guide](/docs/guides/customizing-clerk/adding-items/organization-profile).
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash- and virtual-based routing. For example: `/organization-profile`.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
In addition, you also can add custom pages and links to the `` navigation sidenav. For more information, refer to the [Custom Pages](/docs/guides/customizing-clerk/adding-items/organization-profile) documentation.
---
title: "``"
description: The component is a button that links to the sign-in
page or displays the sign-in modal.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/unstyled/sign-in-button
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: astro
sourceFile: /docs/reference/components/unstyled/sign-in-button.mdx
---
The `` component is a button that, by default, links to your app's sign-in page. Your sign-in page will be hosted by Clerk using the [Account Portal](/docs/guides/customizing-clerk/account-portal) unless you have set up a dedicated sign-in page.
## Usage
### Basic usage
```astro {{ filename: 'pages/sign-in.astro' }}
---
import { SignInButton } from '@clerk/astro/components'
---
```
### Custom usage
You can create a custom button by wrapping your own button, or button text, in the `` component.
You must pass the `asChild` prop to the `` component if you are passing children to it.
```astro {{ filename: 'pages/index.astro' }}
---
import { SignInButton } from '@clerk/astro/components'
---
Custom sign in button
```
## Properties
* `forceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs in. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `fallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `oauthFlow`
* `"redirect" | "popup" | "auto"`
Determines how OAuth authentication is performed. Accepts the following properties:
* `"redirect"`: Redirect to the OAuth provider on the current page.
* `"popup"`: Open a popup window.
* `"auto"`: Choose the best method based on whether the current domain typically requires the `"popup"` flow to correctly perform authentication.
Defaults to `"auto"`.
***
* `signUpForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs up. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpFallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `mode?`
* `'redirect' | 'modal'`
Determines what happens when a user clicks on the ``. Setting this to `'redirect'` will redirect the user to the sign-in route. Setting this to `'modal'` will open a modal on the current route. Defaults to `'redirect'`.
***
* `children?`
* `React.ReactNode`
Children you want to wrap the `` in.
***
* `initialValues`
* SignInInitialValues
The values used to prefill the sign-in fields with.
* `asChild?`
* `boolean`
If `true`, the `` component will render its children as a child of the component.
---
title: "``"
description: The `` component is a button that signs a user out.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/unstyled/sign-out-button
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: astro
sourceFile: /docs/reference/components/unstyled/sign-out-button.mdx
---
The `` component is a button that signs a user out. By default, it is a `` tag that says **Sign Out**, but it is completely customizable by passing children.
## Usage
### Basic usage
```astro {{ filename: 'pages/sign-out.astro' }}
---
import { SignOutButton } from '@clerk/astro/components'
---
```
### Custom usage
You can create a custom button by wrapping your own button, or button text, in the `` component.
You must pass the `asChild` prop to the `` component if you are passing children to it.
```astro {{ filename: 'pages/index.astro' }}
---
import { SignOutButton } from '@clerk/astro/components'
---
Custom sign out button
```
### Multi-session usage
#### Sign out of all sessions
Clicking the `` component signs the user out of all sessions. This is the default behavior.
#### Sign out of a specific session
You can sign out of a specific session by passing in a `sessionId` to the `sessionId` prop. This is useful for signing a single account out of a [multi-session application](/docs/guides/secure/session-options#multi-session-applications).
In the following example, the `sessionId` is retrieved from the useAuth() hook. If the user is not signed in, the `sessionId` will be `null`, and the user is shown the \ component. If the user is signed in, the user is shown the `` component, which when clicked, signs the user out of that specific session.
```astro {{ filename: 'pages/index.astro' }}
---
import { SignInButton, SignOutButton } from '@clerk/astro/components'
import { useAuth } from '@clerk/astro/react'
const { sessionId } = useAuth()
---
{sessionId ? : }
```
## Properties
* `redirectUrl?`
* `string`
The full URL or path to navigate after successful sign-out.
***
* `sessionId?`
* `string`
The ID of a specific session to sign out of. Useful for [multi-session applications](/docs/guides/secure/session-options#multi-session-applications).
***
* `children?`
* `React.ReactNode`
Children you want to wrap the `` in.
* `asChild?`
* `boolean`
If `true`, the `` component will render its children as a child of the component.
---
title: "``"
description: The component is a button that links to the sign-up
page or displays the sign-up modal.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/unstyled/sign-up-button
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: astro
sourceFile: /docs/reference/components/unstyled/sign-up-button.mdx
---
The `` component is a button that, by default, links to your app's sign-up page. Your sign-up page will be hosted by Clerk using the [Account Portal](/docs/guides/customizing-clerk/account-portal) unless you have set up a dedicated sign-up page.
## Usage
### Basic usage
```astro {{ filename: 'pages/sign-up.astro' }}
---
import { SignUpButton } from '@clerk/astro/components'
---
```
### Custom usage
You can create a custom button by wrapping your own button, or button text, in the `` component.
You must pass the `asChild` prop to the `` component if you are passing children to it.
```astro {{ filename: 'src/pages/index.astro' }}
---
import { SignUpButton } from '@clerk/astro/components'
---
Custom sign up button
```
## Properties
* `forceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs up. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `fallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `oauthFlow`
* `"redirect" | "popup" | "auto"`
Determines how OAuth authentication is performed. Accepts the following properties:
* `"redirect"`: Redirect to the OAuth provider on the current page.
* `"popup"`: Open a popup window.
* `"auto"`: Choose the best method based on whether the current domain typically requires the `"popup"` flow to correctly perform authentication.
Defaults to `"auto"`.
***
* `signInForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs in. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signInFallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `mode?`
* `'redirect' | 'modal'`
Determines what happens when a user clicks on the ``. Setting this to `'redirect'` will redirect the user to the sign-up route. Setting this to `'modal'` will open a modal on the current route. Defaults to `'redirect'`
***
* `children?`
* `React.ReactNode`
Children you want to wrap the `` in.
***
* `initialValues`
* SignUpInitialValues
The values used to prefill the sign-up fields with.
***
* `unsafeMetadata`
* SignUpUnsafeMetadata
Metadata that can be read and set from the frontend and the backend. Once the sign-up is complete, the value of this field will be automatically copied to the created user's unsafe metadata (`User.unsafeMetadata`). One common use case is to collect custom information about the user during the sign-up process and store it in this property. Read more about [unsafe metadata](/docs/guides/users/extending#unsafe-metadata).
* `asChild?`
* `boolean`
If `true`, the `` component will render its children as a child of the component.
---
title: "`` component"
description: Clerk's component is used to render the familiar
user button UI popularized by Google.
search:
rank: 1
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/user/user-button
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: astro
sourceFile: /docs/reference/components/user/user-button.mdx
---
{{ style: { maxWidth: '436px' } }}
The `` component renders the familiar user button UI popularized by Google. When selected, it opens a dropdown menu with options to manage account settings and sign out. The "Manage account" option launches the \ component, providing access to profile and security settings.
For users that have [multi-session](/docs/guides/secure/session-options#multi-session-applications) enabled, the `` also allows users to sign into multiple accounts at once and instantly switch between them without the need for a full page reload. Learn more [here](/docs/guides/secure/session-options#multi-session-applications).
## Example
In the following example, `` is mounted inside a header component, which is a common pattern on many websites and applications. When the user is signed in, they will see their avatar and be able to open the popup menu.
```astro {{ filename: 'pages/index.astro' }}
---
import { SignedIn, UserButton, SignInButton, SignedOut } from '@clerk/astro/components'
---
```
## Properties
The `` component accepts the following properties, all of which are **optional**:
* `afterMultiSessionSingleSignOutUrl` (deprecated)
* `string`
**Deprecated. Move `afterMultiSessionSingleSignOutUrl` to \.** The full URL or path to navigate to after signing out from a currently active account in a multi-session app.
***
* `afterSignOutUrl` (deprecated)
* `string`
**Deprecated. Move `afterSignOutUrl` to \.** The full URL or path to navigate to after a successful sign-out.
***
* `afterSwitchSessionUrl`
* `string`
The full URL or path to navigate to after a successful account change in a multi-session app.
***
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `defaultOpen`
* `boolean`
Controls whether the `` should open by default during the first render.
***
* `showName`
* `boolean`
Controls if the user name is displayed next to the user image button.
***
* `signInUrl`
* `string`
The full URL or path to navigate to when the **Add another account** button is clicked. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `userProfileMode`
* `'modal' | 'navigation'`
Controls whether selecting the **Manage your account** button will cause the \ component to open as a modal, or if the browser will navigate to the `userProfileUrl` where `` is mounted as a page. Defaults to: `'modal'`.
***
* `userProfileProps`
* `object`
Specify options for the underlying \ component. For example: `{additionalOAuthScopes: {google: ['foo', 'bar'], github: ['qux']}}`.
***
* `userProfileUrl`
* `string`
The full URL or path leading to the user management interface.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
You can also [add custom actions and links to the `` menu](/docs/guides/customizing-clerk/adding-items/user-button).
---
title: "`` component"
description: Clerk's component is used to render a beautiful,
full-featured account management UI that allows users to manage their profile
and security settings.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/user/user-profile
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: astro
sourceFile: /docs/reference/components/user/user-profile.mdx
---
{{ style: { maxWidth: '100%' } }}
The `` component is used to render a beautiful, full-featured account management UI that allows users to manage their profile, security, and billing settings.
## Example
```astro {{ filename: 'pages/user.astro' }}
---
import { UserProfile } from '@clerk/astro/components'
---
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash-based routing. For example: `/user-profile`.
***
* `additionalOAuthScopes`
* `object`
Specify additional scopes per OAuth provider that your users would like to provide if not already approved. For example: `{google: ['foo', 'bar'], github: ['qux']}`.
***
* `customPages`
* CustomPage\[]
An array of custom pages to add to the user profile. Only available for the JavaScript SDK. To add custom pages with React-based SDK's, see the [dedicated guide](/docs/guides/customizing-clerk/adding-items/user-profile).
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
In addition, you also can add custom pages and links to the `` navigation sidenav. For more information, refer to the [Custom Pages documentation](/docs/guides/customizing-clerk/adding-items/user-profile).
---
title: "`` component"
description: Clerk's component is used to render the familiar
user avatar on its own.
search:
rank: 1
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/user/user-avatar
lastUpdated: 2025-11-21T23:29:30.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: astro
sourceFile: /docs/reference/components/user/user-avatar.mdx
---

The `` component renders the authenticated user's avatar on its own, a common UI element found across many websites and applications.
## Example
In the following example, `` is mounted inside a header component, which is a common pattern on many websites and applications. When the user is signed in, they will see their avatar.
```astro {{ filename: 'pages/index.astro' }}
---
import { SignedIn, UserAvatar, SignInButton, SignedOut } from '@clerk/astro/components'
---
```
## Properties
The `` component accepts the following properties, all of which are **optional**:
* `rounded?`
* `boolean`
Determines whether the user avatar is displayed with rounded corners.
***
* `appearance?`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback?`
* `ReactNode`
Optional element to be rendered while the component is mounting.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
---
title: Hooks Reference
description: A list of Clerk's comprehensive suite of hooks for managing
authentication, sessions, sign-in and sign-up flows, Organizations, and
reverification.
sdk: astro, chrome-extension, expo, nextjs, react, react-router, remix,
tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/overview
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,react,react-router,remix,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,nuxt,vue,ruby,js-backend
activeSdk: astro
sourceFile: /docs/reference/hooks/overview.mdx
---
Clerk offers a comprehensive suite of hooks that expose low-level access to authentication, session management, and multi-tenancy. With Clerk hooks, you can access and manage user data, handle sign-in and sign-up flows, control session management, and implement advanced flows like session reverification for sensitive actions. By using these hooks, you can extend or replace Clerk's built-in components and customize how authentication behaves in your application.
## Hooks
* useUser()
* useClerk()
* useAuth()
* useSignIn()
* useSignUp()
* useSession()
* useSessionList()
* useOrganization()
* useOrganizationList()
* useReverification()
* useCheckout()
* usePaymentElement()
* usePaymentMethods()
* usePlans()
* useSubscription()
* useStatements()
* usePaymentAttempts()
* [Join our Discord](https://clerk.com/discord "Join Discord")
* Join our official Discord server to chat with us directly and become a part of the Clerk community.
* {}
***
* [Need help?](/support "Get help")
* Contact us through Discord, Twitter, or email to receive answers to your questions and learn more about Clerk.
* {}
---
title: useAuth()
description: Access and manage authentication state in your application with
Clerk's useAuth() hook.
sdk: astro, chrome-extension, expo, nextjs, react, react-router,
tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-auth
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,react,react-router,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,remix,go,nuxt,vue,ruby,js-backend
activeSdk: astro
sourceFile: /docs/reference/hooks/use-auth.mdx
---
The `useAuth()` hook provides access to the current user's authentication state and methods to manage the active session.
> \[!NOTE]
> To access auth data server-side, see the Auth object reference doc.
## Parameters
| Parameter | Type | Description |
| ---------------------------- | -------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `initialAuthStateOrOptions?` | null \| Record\ \| \{ treatPendingAsSignedOut?: boolean; \} | An object containing the initial authentication state or options for the `useAuth()` hook. If not provided, the hook will attempt to derive the state from the context. `treatPendingAsSignedOut` is a boolean that indicates whether pending sessions are considered as signed out or not. Defaults to `true`. |
## Returns
There are multiple variants of this type available which you can select by clicking on one of the tabs.
| Name | Type | Description |
| ------ | ------ | ------ |
| `actor` | `undefined` | The JWT actor for the session. Holds identifier for the user that is impersonating the current user. Read more about [impersonation](/docs/guides/users/impersonation). |
| `getToken()` | (options?: GetTokenOptions) => Promise\ | A function that retrieves the current user's session token or a custom JWT template. Returns a promise that resolves to the token. See the reference doc. |
| `has` | `undefined` | A function that checks if the user has specific permissions or roles. See the reference doc. |
| `isLoaded` | `false` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `undefined` | A boolean that indicates whether a user is currently signed in. |
| `orgId` | `undefined` | The ID of the user's active organization. |
| `orgRole` | `undefined` | The current user's role in their active organization. |
| `orgSlug` | `undefined` | The URL-friendly identifier of the user's active organization. |
| `sessionClaims` | `undefined` | The current user's [session claims](/docs/guides/sessions/session-tokens). |
| `sessionId` | `undefined` | The ID for the current session. |
| `signOut()` | \{ (options?: SignOutOptions): Promise\; (signOutCallback?: SignOutCallback, options?: SignOutOptions): Promise\; \} | A function that signs out the current user. Returns a promise that resolves when complete. See the reference doc. |
| `userId` | `undefined` | The ID of the current user. |
| Name | Type | Description |
| ------ | ------ | ------ |
| `actor` | `null` | The JWT actor for the session. Holds identifier for the user that is impersonating the current user. Read more about [impersonation](/docs/guides/users/impersonation). |
| `getToken()` | (options?: GetTokenOptions) => Promise\ | A function that retrieves the current user's session token or a custom JWT template. Returns a promise that resolves to the token. See the reference doc. |
| `has()` | (params: CheckAuthorizationParamsWithCustomPermissions) => false | A function that checks if the user has specific permissions or roles. See the reference doc. |
| `isLoaded` | `true` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `false` | A boolean that indicates whether a user is currently signed in. |
| `orgId` | `null` | The ID of the user's active organization. |
| `orgRole` | `null` | The current user's role in their active organization. |
| `orgSlug` | `null` | The URL-friendly identifier of the user's active organization. |
| `sessionClaims` | `null` | The current user's [session claims](/docs/guides/sessions/session-tokens). |
| `sessionId` | `null` | The ID for the current session. |
| `signOut()` | \{ (options?: SignOutOptions): Promise\; (signOutCallback?: SignOutCallback, options?: SignOutOptions): Promise\; \} | A function that signs out the current user. Returns a promise that resolves when complete. See the reference doc. |
| `userId` | `null` | The ID of the current user. |
| Name | Type | Description |
| ------ | ------ | ------ |
| `actor` | null \| \{ \[x: string]: unknown; sub: string; \} | The JWT actor for the session. Holds identifier for the user that is impersonating the current user. Read more about [impersonation](/docs/guides/users/impersonation). |
| `getToken()` | (options?: GetTokenOptions) => Promise\ | A function that retrieves the current user's session token or a custom JWT template. Returns a promise that resolves to the token. See the reference doc. |
| `has()` | (isAuthorizedParams: CheckAuthorizationParamsWithCustomPermissions) => boolean | A function that checks if the user has specific permissions or roles. See the reference doc. |
| `isLoaded` | `true` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `true` | A boolean that indicates whether a user is currently signed in. |
| `orgId` | `null` | The ID of the user's active organization. |
| `orgRole` | `null` | The current user's role in their active organization. |
| `orgSlug` | `null` | The URL-friendly identifier of the user's active organization. |
| `sessionClaims` | `JwtPayload` | The current user's [session claims](/docs/guides/sessions/session-tokens). |
| `sessionId` | `string` | The ID for the current session. |
| `signOut()` | \{ (options?: SignOutOptions): Promise\; (signOutCallback?: SignOutCallback, options?: SignOutOptions): Promise\; \} | A function that signs out the current user. Returns a promise that resolves when complete. See the reference doc. |
| `userId` | `string` | The ID of the current user. |
| Name | Type | Description |
| ------ | ------ | ------ |
| `actor` | null \| \{ \[x: string]: unknown; sub: string; \} | The JWT actor for the session. Holds identifier for the user that is impersonating the current user. Read more about [impersonation](/docs/guides/users/impersonation). |
| `getToken()` | (options?: GetTokenOptions) => Promise\ | A function that retrieves the current user's session token or a custom JWT template. Returns a promise that resolves to the token. See the reference doc. |
| `has()` | (isAuthorizedParams: CheckAuthorizationParamsWithCustomPermissions) => boolean | A function that checks if the user has specific permissions or roles. See the reference doc. |
| `isLoaded` | `true` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `true` | A boolean that indicates whether a user is currently signed in. |
| `orgId` | `string` | The ID of the user's active organization. |
| `orgRole` | `string` | The current user's role in their active organization. |
| `orgSlug` | null \| string | The URL-friendly identifier of the user's active organization. |
| `sessionClaims` | `JwtPayload` | The current user's [session claims](/docs/guides/sessions/session-tokens). |
| `sessionId` | `string` | The ID for the current session. |
| `signOut()` | \{ (options?: SignOutOptions): Promise\; (signOutCallback?: SignOutCallback, options?: SignOutOptions): Promise\; \} | A function that signs out the current user. Returns a promise that resolves when complete. See the reference doc. |
| `userId` | `string` | The ID of the current user. |
## Example
The following example demonstrates how to use the `useAuth()` hook to access the current auth state, like whether the user is signed in or not. It also includes a basic example for using the `getToken()` method to retrieve a session token for fetching data from an external resource.
```tsx {{ filename: 'src/components/external-data.jsx' }}
import { useAuth } from '@clerk/astro/react'
import { useState } from 'react'
export default function ExternalData() {
const { userId, sessionId, getToken, isLoaded, isSignedIn } = useAuth()
const [data, setData] = useState(null)
const fetchExternalData = async () => {
const token = await getToken()
const response = await fetch('https://api.example.com/data', {
headers: {
Authorization: `Bearer ${token}`,
},
})
const json = await response.json()
setData(json)
}
// Handle loading state
if (!isLoaded) return
Loading...
// Protect the page from unauthenticated users
if (!isSignedIn) return
Sign in to view this page
return (
Hello, {userId}! Your current active session is {sessionId}.
Fetch Data
{data &&
{JSON.stringify(data, null, 2)}
}
)
}
```
```astro {{ filename: 'src/pages/auth.astro' }}
---
import ExternalData from '../components/external-data'
---
```
---
title: Component Reference
description: A list of Clerk's comprehensive suite of components designed to
seamlessly integrate authentication and multi-tenancy into your application.
sdk: react, nextjs, js-frontend, chrome-extension, expo, android, expressjs,
fastify, react-router, remix, tanstack-react-start, go, astro, nuxt, vue,
ruby, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/overview
lastUpdated: 2025-11-21T23:29:30.000Z
availableSdks: react,nextjs,js-frontend,chrome-extension,expo,android,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
notAvailableSdks: ios
activeSdk: go
sourceFile: /docs/reference/components/overview.mdx
---
Clerk offers a comprehensive suite of components designed to seamlessly integrate authentication and multi-tenancy into your application. With Clerk components, you can easily customize the appearance of authentication components and pages, manage the entire authentication flow to suit your specific needs, and even build robust SaaS applications.
## Authentication components
* \
* \
* \
* \
* \
## User components
* \
* \
* \
## Organization components
* \
* \
* \
* \
## Billing components
* \
* \
* \
* \
## Control components
Control components manage authentication-related behaviors in your application. They handle tasks such as controlling content visibility based on user authentication status, managing loading states during authentication processes, and redirecting users to appropriate pages. Control components render at `` and `` states for assertions on the Clerk object. A common example is the \ component, which allows you to conditionally render content only when a user is authenticated.
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
## Unstyled components
* \
* \
* \
* \
## Customization guides
* [Customize components with the `appearance` prop](/docs/guides/customizing-clerk/appearance-prop/overview)
* [Localize components with the `localization` prop (experimental)](/docs/guides/customizing-clerk/localization)
* [Add pages to the `` component](/docs/guides/customizing-clerk/adding-items/user-profile)
* [Add pages to the `` component](/docs/guides/customizing-clerk/adding-items/organization-profile)
### Secured by Clerk branding
> \[!WARNING]
> This feature requires a [paid plan](/pricing){{ target: '_blank' }} for production use, but all features are free to use in development mode so that you can try out what works for you. See the [pricing](/pricing){{ target: '_blank' }} page for more information.
By default, Clerk displays a **Secured by Clerk** badge on Clerk components. You can remove this branding by following these steps:
1. In the Clerk Dashboard, navigate to your application's [**Settings**](https://dashboard.clerk.com/~/settings).
2. Under **Branding**, toggle on the **Remove "Secured by Clerk" branding** option.
* [Join our Discord](https://clerk.com/discord "Join Discord")
* Join our official Discord server to chat with us directly and become a part of the Clerk community.
* {}
***
* [Need help?](/support "Get help")
* Contact us through Discord, Twitter, or email to receive answers to your questions and learn more about Clerk.
* {}
---
title: Clerk Go SDK
description: Learn how to integrate Clerk into your Go application using the Clerk Go SDK.
sdk: nextjs, react, js-frontend, chrome-extension, expo, android, ios,
expressjs, fastify, react-router, remix, tanstack-react-start, go, astro,
nuxt, vue, ruby, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/getting-started/quickstart
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,react,js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
notAvailableSdks: ""
activeSdk: go
sourceFile: /docs/getting-started/quickstart.go.mdx
---
The [Clerk Go SDK](/docs/reference/go/overview) is built on top of the [Clerk Backend API](/docs/reference/backend-api){{ target: '_blank' }}.
## Installation
If you're using Go Modules and have a `go.mod` file in your project's root, you can import `clerk-sdk-go` directly in your `.go` files:
```go
import (
"github.com/clerk/clerk-sdk-go/v2"
)
```
Alternatively, you can `go get` the package explicitly and it will add the necessary dependencies to your `go.mod` file:
```sh {{ filename: 'terminal' }}
go get -u github.com/clerk/clerk-sdk-go/v2
```
## Usage
For details on how to use this module, see the [Go Documentation](https://pkg.go.dev/github.com/clerk/clerk-sdk-go/v2).
The Clerk Go SDK is organized using a resource-based structure similar to the [Clerk Backend API](/docs/reference/backend-api){{ target: '_blank' }}. Each API supports specific operations, like `Create` or `List`. For example, the [`actortoken`](https://github.com/clerk/clerk-sdk-go/blob/v2/actortoken/api.go) resource supports the `Create`, `Revoke`, and `GetClient` operations. For the list of supported resources, see [`https://github.com/clerk/clerk-sdk-go/tree/v2`](https://github.com/clerk/clerk-sdk-go/tree/v2) where almost each directory represents a resource.
To execute API operations, you must configure Clerk Go with your Clerk Secret Key. To find your Clerk Secret Key:
1. In the Clerk Dashboard, navigate to the [**API keys**](https://dashboard.clerk.com/~/api-keys) page.
2. In the **Secret Keys** section, copy your Secret Key.
Depending on your use case, there are two ways to use the Clerk Go SDK:
* Without a client: The best option if you're using one API key.
* With a client: The best option if you're using more than one API key.
For most use cases, the API **without** a client is a better choice as it requires a minimal setup and provides a more concise API for invoking operations. However, if you need to operate on multiple Clerk instances from one application, or need more flexibility for tests and mocking, you can instantiate multiple API clients with different API keys.
The following examples demonstrate both approaches.
### Usage without a client
If you only use one API key, you can import the packages required for the APIs you need. Then you can execute your desired request methods as functions, such as `$resource$.Get()` or `$resource$.Delete()`, where `$resource$` is the resource you want to interact with, such as [`user`](https://github.com/clerk/clerk-sdk-go/blob/v2/user/api.go).
```go {{ filename: 'main.go' }}
package main
import (
"context"
"github.com/clerk/clerk-sdk-go/v2"
"github.com/clerk/clerk-sdk-go/v2/user"
)
func main() {
// Each operation requires a context.Context as the first argument
ctx := context.Background()
// Set the API key with your Clerk Secret Key
clerk.SetKey("{{secret}}")
// Create a new user
newUser, err := user.Create(ctx, &user.CreateParams{})
if err != nil {
// Handle error
}
// Get user details
userDetails, err := user.Get(ctx, "user_id")
if err != nil {
// Handle error
}
// List users
userList, err := user.List(ctx, &user.ListParams{})
if err != nil {
// Handle error
}
for _, u := range userList.Users {
// Process each user
}
// Delete user
deletedResource, err := user.Delete(ctx, "user_id")
if err != nil {
// Handle error
}
}
```
#### Example
The following example demonstrates how to use the Clerk Go SDK to execute [Clerk Backend API](/docs/reference/backend-api){{ target: '_blank' }} operations.
By executing the code in the snippet below, you will:
* Create an Organization and update its slug.
* Fetch all Organization memberships and loop through them to get the first one.
* Get more details about the Organization's user.
> \[!NOTE]
> Your Clerk Secret Key is required. If you're signed into the Clerk Dashboard, your Secret Key should become visible by selecting the eye icon. Otherwise, you can retrieve your Clerk Secret Key on the [**API keys**](https://dashboard.clerk.com/~/api-keys) page in the Clerk Dashboard.
```go {{ filename: 'main.go' }}
import (
"github.com/clerk/clerk-sdk-go/v2"
"github.com/clerk/clerk-sdk-go/v2/organization"
"github.com/clerk/clerk-sdk-go/v2/organizationmembership"
"github.com/clerk/clerk-sdk-go/v2/user"
)
func main() {
// Each API operation requires a context.Context as the first argument.
ctx := context.Background()
// Set the API key
clerk.SetKey("{{secret}}")
// Create an organization
org, err := organization.Create(ctx, &organization.CreateParams{
Name: clerk.String("Clerk Inc"),
})
if err != nil {
// You can get additional information on the error, if it can
// be type-cast to clerk.APIErrorResponse.
if apiErr, ok := err.(*clerk.APIErrorResponse); ok {
apiErr.TraceID
apiErr.Error()
apiErr.Response.RawJSON
}
// handle the error
panic(err)
}
// Update the organization
org, err = organization.Update(ctx, org.ID, &organization.UpdateParams{
Slug: clerk.String("clerk"),
})
if err != nil {
// handle the error
panic(err)
}
// List organization memberships
listParams := organizationmembership.ListParams{}
listParams.Limit = clerk.Int64(10)
memberships, err := organizationmembership.List(ctx, params)
if err != nil {
// handle the error
panic(err)
}
if memberships.TotalCount < 0 {
return
}
membership := memberships[0]
// Get a user
usr, err := user.Get(ctx, membership.UserID)
if err != nil {
// handle the error
panic(err)
}
}
```
### Usage with a client
If you're working with multiple keys, it's recommended to use Clerk Go with a client. The API packages for each resource export a `Client`, which supports all the API's operations. This way, you can create as many clients as needed, each with their own API key, as shown in the following example:
```go {{ filename: 'main.go' }}
package main
import (
"context"
"github.com/clerk/clerk-sdk-go/v2"
"github.com/clerk/clerk-sdk-go/v2/user"
)
func main() {
// Each operation requires a context.Context as the first argument.
ctx := context.Background()
// Initialize a client with an API key
config := &clerk.ClientConfig{}
config.Key = "{{secret}}"
client := user.NewClient(config)
// Create a new user
newUser, err := client.Create(ctx, &user.CreateParams{})
if err != nil {
// Handle error
}
// Get user details
userDetails, err := client.Get(ctx, "user_id")
if err != nil {
// Handle error
}
// List users
userList, err := client.List(ctx, &user.ListParams{})
if err != nil {
// Handle error
}
for _, u := range userList.Users {
// Process each user
}
// Delete user
deletedResource, err := client.Delete(ctx, "user_id")
if err != nil {
// Handle error
}
}
```
---
title: TanStack React Start Quickstart (beta)
description: Learn how to use Clerk to quickly and easily add secure
authentication and user management to your TanStack React Start application.
sdk: nextjs, react, js-frontend, chrome-extension, expo, android, ios,
expressjs, fastify, react-router, remix, tanstack-react-start, go, astro,
nuxt, vue, ruby, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/getting-started/quickstart
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,react,js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
notAvailableSdks: ""
activeSdk: tanstack-react-start
sourceFile: /docs/getting-started/quickstart.tanstack-react-start.mdx
---
> \[!WARNING]
> The TanStack React Start SDK is currently in beta. **It is not yet recommended for production use**.
## Install `@clerk/tanstack-react-start`
The [Clerk TanStack React Start SDK](/docs/reference/tanstack-react-start/overview) gives you access to prebuilt components, React hooks, and helpers to make user authentication easier.
Run the following command to install the SDK:
```npm {{ filename: 'terminal' }}
npm install @clerk/tanstack-react-start
```
## Set your Clerk API keys
Add the following keys to your `.env` file. These keys can always be retrieved from the [**API keys**](https://dashboard.clerk.com/~/api-keys) page in the Clerk Dashboard.
1. In the Clerk Dashboard, navigate to the [**API keys**](https://dashboard.clerk.com/~/api-keys) page.
2. In the **Quick Copy** section, copy your Clerk Publishable and Secret Keys.
3. Paste your keys into your `.env` file.
The final result should resemble the following:
```env {{ filename: '.env' }}
VITE_CLERK_PUBLISHABLE_KEY={{pub_key}}
CLERK_SECRET_KEY={{secret}}
```
## Add `clerkMiddleware()` to your app
[`clerkMiddleware()`](/docs/reference/tanstack-react-start/clerk-middleware) grants you access to user authentication state throughout your app, on any server function or route.
Create a `src/start.ts` file with the following code:
```tsx {{ filename: 'src/start.ts' }}
import { clerkMiddleware } from '@clerk/tanstack-react-start/server'
import { createStart } from '@tanstack/react-start'
export const startInstance = createStart(() => {
return {
requestMiddleware: [clerkMiddleware()],
}
})
```
## Add `` to your app
The \ component provides session and user context to Clerk's hooks and components. It's recommended to wrap your entire app at the entry point with `` to make authentication globally accessible. See the reference docs for other configuration options.
Add the `` component to your app's root route, as shown in the following example:
```tsx {{ filename: 'src/routes/__root.tsx', ins: [1, 37, 59], fold: [[2, 34]] }}
import { ClerkProvider } from '@clerk/tanstack-react-start'
import { HeadContent, Scripts, createRootRoute } from '@tanstack/react-router'
import { TanStackRouterDevtoolsPanel } from '@tanstack/react-router-devtools'
import { TanStackDevtools } from '@tanstack/react-devtools'
import Header from '../components/Header'
import appCss from '../styles.css?url'
export const Route = createRootRoute({
head: () => ({
meta: [
{
charSet: 'utf-8',
},
{
name: 'viewport',
content: 'width=device-width, initial-scale=1',
},
{
title: 'TanStack Start Starter',
},
],
links: [
{
rel: 'stylesheet',
href: appCss,
},
],
}),
shellComponent: RootDocument,
})
function RootDocument({ children }: { children: React.ReactNode }) {
return (
{children}
,
},
]}
/>
)
}
```
## Protect your pages
### Client-side
To protect your pages on the client-side, you can use Clerk's prebuilt control components that control the visibility of content based on the user's authentication state.
The following example uses the following components:
* \: Children of this component can only be seen while **signed in**.
* \: Children of this component can only be seen while **signed out**.
* \: Shows the signed-in user's avatar. Selecting it opens a dropdown menu with account management options.
* \: An unstyled component that links to the sign-in page. In this example, since no props or [environment variables](/docs/guides/development/clerk-environment-variables) are set for the sign-in URL, this component links to the [Account Portal sign-in page](/docs/guides/customizing-clerk/account-portal#sign-in).
```tsx {{ filename: 'src/routes/index.tsx' }}
import { SignedIn, UserButton, SignedOut, SignInButton } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
function Home() {
return (
Index Route
You are signed in
You are signed out
)
}
```
### Server-side
To protect your routes, create a [server function](https://tanstack.com/start/latest/docs/framework/react/guide/server-functions) that checks the user's authentication state via the [`auth()`](/docs/reference/tanstack-react-start/auth) method. If the user is not authenticated, they are redirected to a sign-in page. If authenticated, the user's `userId` is passed to the route, allowing access to the `` component, which welcomes the user and displays their `userId`. The [`beforeLoad()`](https://tanstack.com/router/latest/docs/framework/react/api/router/RouteOptionsType#beforeload-method) method ensures authentication is checked before loading the page, and the [`loader()`](https://tanstack.com/router/latest/docs/framework/react/api/router/RouteOptionsType#loader-method) method returns the user data for use in the component.
> \[!TIP]
> Ensure that your app has the [TanStack Start server handler](https://tanstack.com/start/latest/docs/framework/react/guide/server-routes#handling-server-route-requests) configured in order for your server routes to work.
```tsx {{ filename: 'src/routes/index.tsx' }}
import { createFileRoute, redirect } from '@tanstack/react-router'
import { createServerFn } from '@tanstack/react-start'
import { auth } from '@clerk/tanstack-react-start/server'
const authStateFn = createServerFn({ method: 'GET' }).handler(async () => {
const { isAuthenticated, userId } = await auth()
if (!isAuthenticated) {
// This will error because you're redirecting to a path that doesn't exist yet
// You can create a sign-in route to handle this
// See https://clerk.com/docs/tanstack-react-start/guides/development/custom-sign-in-or-up-page
throw redirect({
to: '/sign-in',
})
}
return { userId }
})
export const Route = createFileRoute('/')({
component: Home,
beforeLoad: async () => await authStateFn(),
loader: async ({ context }) => {
return { userId: context.userId }
},
})
function Home() {
const state = Route.useLoaderData()
return
Welcome! Your ID is {state.userId}!
}
```
## Create your first user
Run your project with the following command:
```npm
npm run dev
```
Visit your app's homepage at [http://localhost:3000](http://localhost:3000). Sign up to create your first user.
## Next steps
* [Core concepts](/docs/getting-started/core-concepts)
* Before building your application, it's important to understand the core concepts and objects that drive Clerk's powerful authentication and user management system.
***
* [Add a custom sign-in-or-up page](/docs/tanstack-react-start/guides/development/custom-sign-in-or-up-page)
* Learn how to create a custom sign-in-or-up page using Clerk's prebuilt components.
***
* [Protect content and read user data](/docs/tanstack-react-start/guides/users/reading)
* Learn how to use Clerk's hooks and helpers to protect content and read session and user data.
***
* [Clerk components](/docs/reference/components/overview)
* Learn more about Clerk's prebuilt components.
---
title: Clerk Billing for B2B SaaS
description: Clerk Billing is a feature that allows you to create and manage
Plans and Features for your application.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/billing/for-b2b
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: tanstack-react-start
sourceFile: /docs/guides/billing/for-b2b.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing for B2B SaaS allows you to create Plans and manage Subscriptions **for companies or organizations** in your application. If you'd like to charge individual users, see Billing for B2C SaaS. You can also combine both B2C and B2B Billing in the same application.
## Enable Billing
To enable Billing for your application, navigate to the [**Billing Settings**](https://dashboard.clerk.com/~/billing/settings) page in the Clerk Dashboard. This page will guide you through enabling Billing for your application.
Clerk Billing costs the same as using Stripe Billing directly, just 0.7% per transaction, plus transaction fees which are paid directly to Stripe. Clerk Billing is **not** the same as Stripe Billing. Plans and pricing are managed directly through the Clerk Dashboard and won't sync with your existing Stripe products or plans. Clerk uses Stripe **only** for payment processing, so you don't need to set up Stripe Billing.
### Payment gateway
Once you have enabled Billing, you will see the following **Payment gateway** options for collecting payments via Stripe:
* **Clerk development gateway**: A shared **test** Stripe account used for development instances. This allows developers to test and build Billing flows **in development** without needing to create and configure a Stripe account.
* **Stripe account**: Use your own Stripe account for production. **A Stripe account created for a development instance cannot be used for production**. You will need to create a separate Stripe account for your production environment.
## Create a Plan
Subscription Plans are what your customers subscribe to. There is no limit to the number of Plans you can create. If your Clerk instance has existing [Custom Permissions](/docs/guides/organizations/roles-and-permissions), the corresponding Features from those Permissions will automatically be added to the free Plan for Orgs. This ensures that Organization members get the same set of Custom Permissions when Billing is enabled, because all Organizations start on the free Plan.
To create a Plan, navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard. Here, you can create, edit, and delete Plans. To setup B2B Billing, select the **Plans for Organizations** tab and select **Add Plan**. When creating a Plan, you can also create [Features](/docs/guides/secure/features) for the Plan; see the next section for more information.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's an Organization Plan, it can appear in the `` component. When creating or editing a Plan, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Add Features to a Plan
[Features](/docs/guides/secure/features) make it easy to give entitlements to your Plans. You can add any number of Features to a Plan.
You can add a Feature to a Plan when you are creating a Plan. To add it after a Plan is created:
1. Navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard.
2. Select the Plan you'd like to add a Feature to.
3. In the **Features** section, select **Add Feature**.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's an Organization Plan, it can appear in the `` component. When adding a Feature to a Plan, it will also automatically appear in the corresponding Plan. When creating or editing a Feature, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Create a pricing page
You can create a pricing page by using the \ component. This component displays a table of Plans and Features that customers can subscribe to. **It's recommended to create a dedicated page**, as shown in the following example.
```tsx {{ filename: 'app/routes/pricing.tsx' }}
import { PricingTable } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: PricingPage,
})
function PricingPage() {
return (
)
}
```
## Control access with Features, Plans, and Permissions
You can use Clerk's Features, Plans, and Permissions to gate access to content using authorization checksAuthorization checks are checks you perform in your code to determine the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions or access certain content. Learn more about [authorization checks](/docs/guides/secure/authorization-checks).. There are a few ways to do this, but the recommended approach is to either use the has() method or the \ component.
The `has()` method is available for any JavaScript-based framework, while `` is a component, and therefore, is only available for React-based frameworks.
> \[!IMPORTANT]
> Permission-based authorization checks link with Feature-based authorization checks. This means that if you are checking a Custom Permission, it will only work if the Feature part of the Permission key (`org::`) **is a Feature included in the Organization's active Plan**. For example, say you want to check if an Organization member has the Custom Permission `org:teams:manage`, where `teams` is the Feature. Before performing the authorization check, you need to ensure that the user's Organization is subscribed to a Plan that has the `teams` Feature. If the user's Organization is not subscribed to a Plan that has the `teams` Feature, the authorization check will always return `false`, *even if the user has the Custom Permission*.
### Example: Using `has()`
Use the `has()` method to test if the Organization has access to a **Plan**:
```jsx
const hasPremiumAccess = has({ plan: 'gold' })
```
Or a **Feature**:
```jsx
const hasPremiumAccess = has({ feature: 'widgets' })
```
The has() method is a server-side helper that checks if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan) and returns a boolean value. `has()` is available on the auth object, which you will access differently depending on the framework you are using.
> \[!TIP]
> Why aren't Custom Permissions appearing in the session token (JWT) or in API responses (including the result of the `has()` check)?
>
> ***
>
> Custom Permissions will only appear in the session token (JWT) and in API responses (including the result of the `has()` check) if the Feature part of the Permission key (`org::`) **is a Feature included in the Organization's active Plan**. If the Feature is not part of the Plan, the `has()` check for Permissions using that Feature will return `false`, and those Permissions will not be represented in the session token.
>
> For example, say you want to check if an Organization member has the Custom Permission `org:teams:manage`, where `teams` is the Feature. The user's Organization must be subscribed to a Plan that has the `teams` Feature for authorization checks to work. If the user's Organization is not subscribed to a Plan that has the `teams` Feature, the authorization check will always return `false`, *even if the user has the Custom Permission*.
The following example demonstrates how to use `has()` to check if an Organization has a Plan.
```tsx {{ filename: 'app/routes/bronze-content.tsx' }}
import { getAuth } from '@clerk/tanstack-react-start/server'
import { createFileRoute } from '@tanstack/react-router'
import { getWebRequest } from '@tanstack/react-start/server'
export const Route = createFileRoute('/bronze-content')({
component: BronzeContentPage,
beforeLoad: async () => {
const request = getWebRequest()
if (!request) throw new Error('Request not found')
return { auth: await getAuth(request) }
},
loader: async ({ context }) => {
return { hasBronzePlan: context.auth.has({ plan: 'bronze' }) }
},
})
function BronzeContentPage() {
const { hasBronzePlan } = Route.useLoaderData()
if (!hasBronzePlan) return
Only subscribers to the Bronze plan can access this content.
return
For Bronze subscribers only
}
```
The following example demonstrates how to use `has()` to check if an Organization has a Feature.
```tsx {{ filename: 'app/routes/premium-content.tsx' }}
import { getAuth } from '@clerk/tanstack-react-start/server'
import { createFileRoute } from '@tanstack/react-router'
import { getWebRequest } from '@tanstack/react-start/server'
export const Route = createFileRoute('/premium-content')({
component: PremiumContentPage,
beforeLoad: async () => {
const request = getWebRequest()
if (!request) throw new Error('Request not found')
return { auth: await getAuth(request) }
},
loader: async ({ context }) => {
return { hasPremiumAccess: context.auth.has({ feature: 'premium_access' }) }
},
})
function PremiumContentPage() {
const { hasPremiumAccess } = Route.useLoaderData()
if (!hasPremiumAccess)
return
Only subscribers with the Premium Access feature can access this content.
return
Our Exclusive Content
}
```
The following example demonstrates how to use `has()` to check if an Organization has a Permission.
```tsx {{ filename: 'app/routes/manage-premium-content.tsx' }}
import { getAuth } from '@clerk/tanstack-react-start/server'
import { createFileRoute } from '@tanstack/react-router'
import { getWebRequest } from '@tanstack/react-start/server'
export const Route = createFileRoute('/manage-premium-content')({
component: ManagePremiumContentPage,
beforeLoad: async () => {
const request = getWebRequest()
if (!request) throw new Error('Request not found')
return { auth: await getAuth(request) }
},
loader: async ({ context }) => {
return {
hasPremiumAccessManage: context.auth.has({ permission: 'org:premium_access:manage' }),
}
},
})
function ManagePremiumContentPage() {
const { hasPremiumAccessManage } = Route.useLoaderData()
if (!hasPremiumAccessManage)
return (
Only subscribers with the Premium Access Manage permission can access this content.
)
return
Our Exclusive Content
}
```
### Example: Using ``
The \ component protects content or even entire routes by checking if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan). You can pass a `fallback` prop to `` that will be rendered if the Organization does not have the access control.
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Plan.
```tsx {{ filename: 'app/routes/protected-content.tsx' }}
import { Protect } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/protected-content')({
component: ProtectedContentPage,
})
function ProtectedContentPage() {
return (
Only subscribers to the Bronze plan can access this content.}
>
Exclusive Bronze Content
This content is only visible to Bronze subscribers.
)
}
```
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Feature.
```tsx {{ filename: 'app/routes/protected-premium-content.tsx' }}
import { Protect } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/protected-premium-content')({
component: ProtectedPremiumContentPage,
})
function ProtectedPremiumContentPage() {
return (
Only subscribers with the Premium Access feature can access this content.}
>
Exclusive Premium Content
This content is only visible to users with Premium Access feature.
)
}
```
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Permission.
```tsx {{ filename: 'app/routes/protected-manage-content.tsx' }}
import { Protect } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/protected-manage-content')({
component: ProtectedManageContentPage,
})
function ProtectedManageContentPage() {
return (
Only subscribers with the Premium Access Manage permission can access this content.
}
>
Exclusive Management Content
This content is only visible to users with Premium Access Manage permission.
)
}
```
---
title: Clerk Billing for B2C SaaS
description: Clerk Billing is a feature that allows you to create and manage
Plans and Features for your application.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/billing/for-b2c
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: tanstack-react-start
sourceFile: /docs/guides/billing/for-b2c.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing for B2C SaaS allows you to create Plans and manage Subscriptions **for individual users** in your application. If you'd like to charge companies or organizations, see Billing for B2B SaaS. You can also combine both B2C and B2B Billing in the same application.
## Enable Billing
To enable Billing for your application, navigate to the [**Billing Settings**](https://dashboard.clerk.com/~/billing/settings) page in the Clerk Dashboard. This page will guide you through enabling Billing for your application.
Clerk Billing costs the same as using Stripe Billing directly, just 0.7% per transaction, plus transaction fees which are paid directly to Stripe. Clerk Billing is **not** the same as Stripe Billing. Plans and pricing are managed directly through the Clerk Dashboard and won't sync with your existing Stripe products or plans. Clerk uses Stripe **only** for payment processing, so you don't need to set up Stripe Billing.
### Payment gateway
Once you have enabled Billing, you will see the following **Payment gateway** options for collecting payments via Stripe:
* **Clerk development gateway**: A shared **test** Stripe account used for development instances. This allows developers to test and build Billing flows **in development** without needing to create and configure a Stripe account.
* **Stripe account**: Use your own Stripe account for production. **A Stripe account created for a development instance cannot be used for production**. You will need to create a separate Stripe account for your production environment.
## Create a Plan
Subscription Plans are what your users subscribe to. There is no limit to the number of Plans you can create.
To create a Plan, navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard. Here, you can create, edit, and delete Plans. To setup B2C Billing, select the **Plans for Users** tab and select **Add Plan**. When creating a Plan, you can also create Features for the Plan; see the next section for more information.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's a user Plan, it can appear in the `` component. When creating or editing a Plan, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Add Features to a Plan
[Features](/docs/guides/secure/features) make it easy to give entitlements to your Plans. You can add any number of Features to a Plan.
You can add a Feature to a Plan when you are creating a Plan. To add it after a Plan is created:
1. Navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard.
2. Select the Plan you'd like to add a Feature to.
3. In the **Features** section, select **Add Feature**.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's a user Plan, it can appear in the `` component. When adding a Feature to a Plan, it will also automatically appear in the corresponding Plan. When creating or editing a Feature, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Create a pricing page
You can create a pricing page by using the \ component. This component displays a table of Plans and Features that users can subscribe to. **It's recommended to create a dedicated page**, as shown in the following example.
```tsx {{ filename: 'app/routes/pricing.tsx' }}
import { PricingTable } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: PricingPage,
})
function PricingPage() {
return (
)
}
```
## Control access with Features and Plans
You can use Clerk's Features and Plans to gate access to the content. There are a few ways to do this, but the recommended approach is to either use the has() method or the \ component.
The `has()` method is available for any JavaScript framework, while `` is only available for React-based frameworks.
### Example: Using `has()`
Use the `has()` method to test if the user has access to a **Plan**:
```jsx
const hasPremiumAccess = has({ plan: 'gold' })
```
Or a **Feature**:
```jsx
const hasPremiumAccess = has({ feature: 'widgets' })
```
The has() method is a server-side helper that checks if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan) and returns a boolean value. `has()` is available on the auth object, which you will access differently depending on the framework you are using.
The following example demonstrates how to use `has()` to check if a user has a Plan.
```tsx {{ filename: 'app/routes/bronze-content.tsx' }}
import { getAuth } from '@clerk/tanstack-react-start/server'
import { createFileRoute } from '@tanstack/react-router'
import { getWebRequest } from '@tanstack/react-start/server'
export const Route = createFileRoute('/bronze-content')({
component: BronzeContentPage,
beforeLoad: async () => {
const request = getWebRequest()
if (!request) throw new Error('Request not found')
return { auth: await getAuth(request) }
},
loader: async ({ context }) => {
return { hasBronzePlan: context.auth.has({ plan: 'bronze' }) }
},
})
function BronzeContentPage() {
const { hasBronzePlan } = Route.useLoaderData()
if (!hasBronzePlan) return
Only subscribers to the Bronze plan can access this content.
return
For Bronze subscribers only
}
```
The following example demonstrates how to use `has()` to check if a user has a Feature.
```tsx {{ filename: 'app/routes/premium-content.tsx' }}
import { getAuth } from '@clerk/tanstack-react-start/server'
import { createFileRoute } from '@tanstack/react-router'
import { getWebRequest } from '@tanstack/react-start/server'
export const Route = createFileRoute('/premium-content')({
component: PremiumContentPage,
beforeLoad: async () => {
const request = getWebRequest()
if (!request) throw new Error('Request not found')
return { auth: await getAuth(request) }
},
loader: async ({ context }) => {
return { hasPremiumAccess: context.auth.has({ feature: 'premium_access' }) }
},
})
function PremiumContentPage() {
const { hasPremiumAccess } = Route.useLoaderData()
if (!hasPremiumAccess)
return
Only subscribers with the Premium Access feature can access this content.
return
Our Exclusive Content
}
```
### Example: Using ``
The \ component protects content or even entire routes by checking if the user has been granted a specific type of access control (Role, Permission, Feature, or Plan). You can pass a `fallback` prop to `` that will be rendered if the user does not have the access control.
The following example demonstrates how to use `` to protect a page by checking if the user has a Plan.
```tsx {{ filename: 'app/routes/protected-content.tsx' }}
import { Protect } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/protected-content')({
component: ProtectedContentPage,
})
function ProtectedContentPage() {
return (
Only subscribers to the Bronze plan can access this content.}
>
Exclusive Bronze Content
This content is only visible to Bronze subscribers.
)
}
```
The following example demonstrates how to use `` to protect a page by checking if the user has a Feature.
```tsx {{ filename: 'app/routes/protected-premium-content.tsx' }}
import { Protect } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/protected-premium-content')({
component: ProtectedPremiumContentPage,
})
function ProtectedPremiumContentPage() {
return (
Only subscribers with the Premium Access feature can access this content.}
>
Exclusive Premium Content
This content is only visible to users with Premium Access feature.
)
}
```
---
title: Build your own sign-in-or-up page for your TanStack React Start app with Clerk
description: Learn how to add a custom sign-in-or-up page to your TanStack React
Start app with Clerk's prebuilt components.
sdk: nextjs, react-router, remix, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/guides/development/custom-sign-in-or-up-page
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,react-router,remix,tanstack-react-start
notAvailableSdks: react,js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/guides/development/custom-sign-in-or-up-page.tanstack-react-start.mdx
---
This guide shows you how to use the \ component to build a custom page **that allows users to sign in or sign up within a single flow**.
To set up separate sign-in and sign-up pages, follow this guide, and then follow the [custom sign-up page guide](/docs/tanstack-react-start/guides/development/custom-sign-up-page).
> \[!NOTE]
> Just getting started with Clerk and TanStack React Start? See the [quickstart tutorial](/docs/tanstack-react-start/getting-started/quickstart)!
## Build a sign-in-or-up page
The following example demonstrates how to render the \ component on a dedicated page using the [TanStack Router catch-all route](https://tanstack.com/router/latest/docs/framework/react/routing/routing-concepts#splat--catch-all-routes).
```tsx {{ filename: 'src/routes/sign-in.$.tsx' }}
import { SignIn } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/sign-in/$')({
component: Page,
})
function Page() {
return
}
```
## Configure your sign-in-or-up page
Set the `CLERK_SIGN_IN_URL` environment variable to tell Clerk where the `` component is being hosted.
There are other environment variables that you can set to customize Clerk's redirect behavior, such as `CLERK_SIGN_IN_FORCE_REDIRECT_URL`. Learn more about these environment variables and how to customize Clerk's redirect behavior in the [dedicated guide](/docs/guides/development/customize-redirect-urls).
```env {{ filename: '.env' }}
CLERK_SIGN_IN_URL=/sign-in
```
## Visit your new page
Run your project with the following command:
```npm
npm run dev
```
Visit your new custom page locally at [localhost:3000/sign-in](http://localhost:3000/sign-in).
## Next steps
* [Create custom sign-up page](/docs/tanstack-react-start/guides/development/custom-sign-up-page)
* Learn how to add a custom sign-up page to your TanStack React Start app with Clerk's prebuilt components.
***
* [Protect content and read user data](/docs/tanstack-react-start/guides/users/reading)
* Learn how to use Clerk's hooks and helpers to access the session and user data in your TanStack React Start application.
---
title: Build your own sign-up page for your TanStack React Start app with Clerk
description: Learn how to add a custom sign-up page to your TanStack React Start
app with Clerk's prebuilt components.
sdk: nextjs, react-router, remix, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/guides/development/custom-sign-up-page
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,react-router,remix,tanstack-react-start
notAvailableSdks: react,js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/guides/development/custom-sign-up-page.tanstack-react-start.mdx
---
By default, the \ component handles signing in and signing up, but if you'd like to have a dedicated sign-up page, this guide shows you how to use the \ component to build a custom sign-up page.
To set up a single sign-in-or-up page, follow the [custom sign-in-or-up page guide](/docs/tanstack-react-start/guides/development/custom-sign-in-or-up-page).
> \[!NOTE]
> Just getting started with Clerk and TanStack React Start? See the [quickstart tutorial](/docs/tanstack-react-start/getting-started/quickstart)!
## Build a sign-up page
The following example demonstrates how to render the \ component on a dedicated sign-up page using the [TanStack Router catch-all route](https://tanstack.com/router/latest/docs/framework/react/routing/routing-concepts#splat--catch-all-routes).
```tsx {{ filename: 'src/routes/sign-up.$.tsx' }}
import { SignUp } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/sign-up/$')({
component: Page,
})
function Page() {
return
}
```
## Configure your sign-up page
* Set the `CLERK_SIGN_UP_URL` environment variable to tell Clerk where the `` component is being hosted.
There are other environment variables that you can set to customize Clerk's redirect behavior, such as `CLERK_SIGN_UP_FORCE_REDIRECT_URL`. Learn more about these environment variables and how to customize Clerk's redirect behavior in the [dedicated guide](/docs/guides/development/customize-redirect-urls).
```env {{ filename: '.env' }}
CLERK_SIGN_UP_URL=/sign-up
```
## Visit your new pages
Run your project with the following command:
```npm
npm run dev
```
Visit your new custom page locally at [localhost:3000/sign-up](http://localhost:3000/sign-up).
## Next steps
* [Protect content and read user data](/docs/tanstack-react-start/guides/users/reading)
* Learn how to use Clerk's hooks and helpers to access the session and user data in your TanStack React Start application.
---
title: Verify OAuth access tokens in your TanStack React Start application with Clerk
description: Learn how to use Clerk's helpers to verify OAuth access tokens in
your TanStack React Start application.
sdk: nextjs, react-router, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/guides/development/verifying-oauth-access-tokens
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,react-router,tanstack-react-start
notAvailableSdks: react,js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,remix,go,astro,nuxt,vue,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/guides/development/verifying-oauth-access-tokens.tanstack-react-start.mdx
---
When building a resource server that needs to accept and verify OAuth access tokens issued by Clerk, it's crucial to verify these tokens on your backend to ensure the request is coming from an authenticated client.
> \[!NOTE]
> OAuth tokens are machine tokens. Machine token usage is free during our public beta period but will be subject to pricing once generally available. Pricing is expected to be competitive and below market averages.
Clerk provides a built-in [`auth()`](/docs/reference/tanstack-react-start/auth) function that supports token validation via the `acceptsToken` parameter. This lets you specify which type(s) of token your API route should accept in your TanStack React Start application.
By default, `acceptsToken` is set to `session_token`, which means OAuth tokens will **not** be accepted unless explicitly configured. You can pass either a **single token type** or an **array of token types** to `acceptsToken`. To learn more about the supported token types, see the [`auth()` parameters documentation](/docs/reference/tanstack-react-start/auth#parameters).
## Example 1: Accepting a single token type
In the following example, the `acceptsToken` parameter is set to only accept `oauth_token`s.
* If the token is invalid or missing, `auth()` will return `null` for `subject` and other properties, and the request will be rejected with a `401` response.
* If the token is valid, it returns the authenticated user's subject and their associated scopes for use in the application logic.
```tsx
export async function clerkAuth({ request }: { request: Request }) {
const { subject, scopes } = await auth({
acceptsToken: 'oauth_token',
})
// If auth() returns null, the token is invalid
if (!subject) {
throw new Error('OAuth access token is invalid')
}
return { subject, scopes }
}
```
## Example 2: Accepting any token type
In the following example, the `acceptsToken` parameter is set to accept any token type.
* If the token is a `session_token`, it logs that the request is from a user session.
* Otherwise, it logs that the request uses a machine token and specifies its type.
```tsx
import { createServerFn } from '@tanstack/react-start'
import { auth } from '@clerk/tanstack-react-start/server'
const authStateFn = createServerFn({ method: 'GET' }).handler(async () => {
const { tokenType } = await auth({ acceptsToken: 'any' })
if (tokenType === 'session_token') {
console.log('This is a session token from a user')
} else {
console.log(`This is a ${tokenType} token`)
}
return {}
})
```
---
title: Clerk Billing webhooks
description: Clerk Billing webhooks allow you to track subscription lifecycles
and monitor payment attempts.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/development/webhooks/billing
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: tanstack-react-start
sourceFile: /docs/guides/development/webhooks/billing.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing supports webhook events that allow you to track information like subscription lifecycles and payments.
## Subscriptions
A subscription is a top-level container unique to each user or organization. Subscription events can help you track billing changes for each of your customers.
| Event Name | Description |
| - | - |
| `subscription.created` | The top-level subscription is created. This usually happens when a user or organization is created. For existing users and organizations, a subscription will be created when Billing is enabled for the application. |
| `subscription.updated` | The top-level subscription is updated. This event is triggered when any property of the subscription has changed, except for status changes. For example, when the subscription items for the payer change. |
| `subscription.active` | The top-level subscription transitions to active from a non-active status. This happens when any subscription item is set to active, including items from the free default Plan. |
| `subscription.pastDue` | The top-level subscription contains a subscription item that has become past due. |
## Subscription items
A subscription item provides details about the relationship between the payer (user or Organization) and a Plan. A top-level subscription may contain multiple subscription items.
There can only be one `active` subscription item per payer and Plan. In addition, the subscription item for the default Plan will always have the same `id` to allow easier tracking of which users and Organizations are not paid customers.
| Event Name | Description |
| - | - |
| `subscriptionItem.updated` | The subscription item is updated. This event is triggered when a property of the subscription item has changed that does not result in a status change. For example, when a subscription item is renewed and the recurring monthly charge succeeds, the status doesn't change (remains `active`), but `period_start` and `period_end` are updated. This results in a `subscriptionItem.updated` event. |
| `subscriptionItem.active` | The subscription item is set to active. For paid Plans, this happens on successful payment. |
| `subscriptionItem.canceled` | The subscription item is canceled. The payer retains Plan features until the end of the current billing period. |
| `subscriptionItem.upcoming` | The subscription item is set as upcoming after the current billing period. This can happen in the case of a deferred Plan change from a higher-priced to lower-priced Plan. In the case a paid Plan is canceled, the subscription item for the default, free Plan will be set as `upcoming`. |
| `subscriptionItem.ended` | The subscription item has ended. |
| `subscriptionItem.abandoned` | The subscription item is abandoned. This can happen to `upcoming` subscription items if the payer subscribes to another Plan, or re-subscribes to a currently canceled Plan. |
| `subscriptionItem.incomplete` | The subscription item is incomplete. This means the payer has started a checkout for a Plan, but the payment hasn't been successfully processed yet. Once payment succeeds, the subscription item transitions to an `active` status. |
| `subscriptionItem.pastDue` | The subscription item is past due because a recurring charge has failed. |
| `subscriptionItem.freeTrialEnding` | The subscription item is a free trial and is ending soon. This event is sent three days before the trial ends. If the trial is shorter than three days, it's sent immediately. |
## Payment attempts
Payment attempts allow you to track successful and failed payments, for both checkout and recurring charges.
Payment attempt events contain a `type`, which can be either `checkout` or `recurring`. You can use these values to determine whether a payment attempt was for a checkout or a subscription item renewal's recurring charge.
| Event Name | Description |
| - | - |
| `paymentAttempt.created` | A payment attempt has been created with `pending` status. It can either succeed or fail in the future. |
| `paymentAttempt.updated` | A payment attempt has been updated to `paid` or `failed` status. |
Looking for other webhook events? To find a list of all the events Clerk supports, navigate to the [**Webhooks**](https://dashboard.clerk.com/~/webhooks) page and select the **Event Catalog** tab.
---
title: Protect content and read user data
description: Learn how to use Clerk's hooks and helpers to protect content and
read user data in your TanStack React Start application.
metadata:
title: Read session and user data in your Tanstack React Start app with Clerk
sdk: nextjs, expo, react-router, remix, tanstack-react-start, astro, nuxt
sdkScoped: "true"
canonical: /docs/:sdk:/guides/users/reading
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,expo,react-router,remix,tanstack-react-start,astro,nuxt
notAvailableSdks: react,js-frontend,chrome-extension,android,ios,expressjs,fastify,go,vue,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/guides/users/reading.tanstack-react-start.mdx
---
Clerk provides a set of [hooks and helpers](/docs/reference/tanstack-react-start/overview#client-side-helpers) that you can use to protect content and read user data in your TanStack React Start application. Here are examples of how to use these helpers in both the client and server-side to get you started.
## Server-side
The [`auth()`](/docs/reference/tanstack-react-start/auth) helper returns the Auth object of the currently active user, which contains important information like the current user's session ID, user ID, and Organization ID, and the `isAuthenticated` property, which can be used to protect your API routes.
In some cases, you may need the full Backend User object of the currently active user. This is helpful if you want to render information, like their first and last name, directly from the server. The `clerkClient()` helper returns an instance of the JS Backend SDK, which exposes Clerk's Backend API resources through methods such as the getUser(){{ target: '_blank' }} method. This method returns the full `Backend User` object.
In the following example, the `userId` is passed to the JS Backend SDK's `getUser()` method to get the user's full `Backend User` object.
```tsx {{ filename: 'src/routes/index.tsx' }}
import { createFileRoute, redirect } from '@tanstack/react-router'
import { createServerFn } from '@tanstack/react-start'
import { clerkClient, auth } from '@clerk/tanstack-react-start/server'
import { UserButton } from '@clerk/tanstack-react-start'
const authStateFn = createServerFn({ method: 'GET' }).handler(async () => {
// The `Auth` object gives you access to properties like `isAuthenticated` and `userId`
// Accessing the `Auth` object differs depending on the SDK you're using
// https://clerk.com/docs/reference/backend/types/auth-object#how-to-access-the-auth-object
const { isAuthenticated, userId } = await auth()
// Protect the server function from unauthenticated users
if (!isAuthenticated) {
// This might error if you're redirecting to a path that doesn't exist yet
// You can create a sign-in route to handle this
// See https://clerk.com/docs/reference/tanstack-react-start/custom-sign-in-or-up-page
throw redirect({
to: '/sign-in/$',
})
}
// Get the user's full `Backend User` object
const user = await clerkClient().users.getUser(userId)
return { userId, firstName: user?.firstName }
})
export const Route = createFileRoute('/')({
component: Home,
beforeLoad: () => authStateFn(),
loader: async ({ context }) => {
return { userId: context.userId, firstName: context.firstName }
},
})
function Home() {
const state = Route.useLoaderData()
return (
Welcome, {state.firstName}!
Your ID is {state.userId}
)
}
```
```ts {{ filename: 'src/routes/api/example.ts' }}
import { auth, clerkClient } from '@clerk/tanstack-react-start/server'
import { json } from '@tanstack/react-start'
import { createFileRoute } from '@tanstack/react-router'
export const ServerRoute = createFileRoute('/api/example')({
server: {
handlers: {
GET: async () => {
// The `Auth` object gives you access to properties like `isAuthenticated` and `userId`
// Accessing the `Auth` object differs depending on the SDK you're using
// https://clerk.com/docs/reference/backend/types/auth-object#how-to-access-the-auth-object
const { isAuthenticated, userId } = await auth()
// Protect the API route from unauthenticated users
if (!isAuthenticated) {
return new Response('User not authenticated', {
status: 404,
})
}
// Get the user's full `Backend User` object
const user = await clerkClient().users.getUser(userId)
// Return the `Backend User` object
return json({ user })
},
},
},
})
```
## Client-side
To access session and user data on the client-side, use Clerk's `useAuth()` and `useUser()` hooks.
### `useAuth()`
{/* TODO: Keep in sync with _partials/hooks/use-auth */}
The useAuth(){{ target: '_blank' }} hook provides information about the current auth state, as well as helper methods to manage the current session.
```tsx {{ filename: 'routes/example.tsx' }}
import { useAuth } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/example')({
component: Example,
})
function Example() {
const { isLoaded, isSignedIn, userId, sessionId, getToken } = useAuth()
const fetchExternalData = async () => {
// Use `getToken()` to get the current user's session token
const token = await getToken()
// Use `token` to fetch data from an external API
const response = await fetch('https://api.example.com/data', {
headers: {
Authorization: `Bearer ${token}`,
},
})
return response.json()
}
// Use `isLoaded` to check if Clerk is loaded
if (!isLoaded) {
return
Loading...
}
// Use `isSignedIn` to check if the user is signed in
if (!isSignedIn) {
// You could also add a redirect to the sign-in page here
return
Sign in to view this page
}
return (
Hello, {userId}! Your current active session is {sessionId}.
)
}
```
### `useUser()`
{/* TODO: Keep in sync with _partials/hooks/use-user */}
The useUser(){{ target: '_blank' }} hook enables you to access the User object, which contains the current user's data such as their full name.
The following example demonstrates how to use `useUser()` to check if the user is signed in and display their first name:
```tsx {{ filename: 'routes/example.tsx' }}
import { useUser } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/example')({
component: Example,
})
function Example() {
const { isLoaded, isSignedIn, user } = useUser()
if (!isLoaded) {
return
Loading...
}
if (!isSignedIn) {
// You could also add a redirect to the sign-in page here
return
Sign in to view this page
}
return
Hello, {user.firstName}!
}
```
---
title: "``"
description: The component provides session and user context to
Clerk's hooks and components.
sdk: chrome-extension, expo, nextjs, react, react-router, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/clerk-provider
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: chrome-extension,expo,nextjs,react,react-router,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,remix,go,astro,nuxt,vue,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/clerk-provider.mdx
---
The `` component is required to integrate Clerk into your React application, providing session and user context to Clerk's hooks and components.
The recommended approach is to wrap your entire app with `` at the entry point to make authentication globally accessible. If you only need authentication for specific routes or pieces of your application, render `` deeper in the component tree. This allows you to implement Clerk's functionality precisely where required without impacting the rest of your app.
## Example
```tsx {{ filename: 'src/routes/__root.tsx', ins: [3, 17, 27] }}
import * as React from 'react'
import { HeadContent, Outlet, Scripts, createRootRoute } from '@tanstack/react-router'
import { ClerkProvider } from '@clerk/tanstack-react-start'
export const Route = createRootRoute({
component: () => {
return (
)
},
})
function RootDocument({ children }: { children: React.ReactNode }) {
return (
{children}
)
}
```
## Properties
| Property | Type | Description |
| ----------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `afterMultiSessionSingleSignOutUrl?` | null \| string | The full URL or path to navigate to after signing out the current user is complete. This option applies to [multi-session applications](/docs/guides/secure/session-options#multi-session-applications). |
| ~~`afterSignInUrl?`~~ | null \| string | **Deprecated.** Use `signInFallbackRedirectUrl` or `signInForceRedirectUrl` instead. |
| `afterSignOutUrl?` | null \| string | Full URL or path to navigate to after successful sign out. |
| ~~`afterSignUpUrl?`~~ | null \| string | **Deprecated.** Use `signUpFallbackRedirectUrl` or `signUpForceRedirectUrl` instead. |
| `allowedRedirectOrigins?` | (string \| RegExp)\[] | An optional array of domains to validate user-provided redirect URLs against. If no match is made, the redirect is considered unsafe and the default redirect will be used with a warning logged in the console. |
| `allowedRedirectProtocols?` | string\[] | An optional array of protocols to validate user-provided redirect URLs against. If no match is made, the redirect is considered unsafe and the default redirect will be used with a warning logged in the console. |
| `appearance?` | [`Appearance`](/docs/guides/customizing-clerk/appearance-prop/overview) | Optional object to style your components. Will only affect Clerk Components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages. |
| `clerkJSUrl?` | `string` | The URL that `@clerk/clerk-js` should be hot-loaded from. |
| `clerkJSVariant?` | "" \| "headless" | If your web application only uses Control Components, you can set this value to `'headless'` and load a minimal ClerkJS bundle for optimal page performance. |
| `clerkJSVersion?` | `string` | The npm version for `@clerk/clerk-js`. |
| `domain?` | string \| (url: URL) => string | **Required if your application is a satellite application**. Sets the domain of the satellite application. |
| `experimental?` | `Autocomplete`\<\{ commerce: boolean; persistClient: boolean; rethrowOfflineNetworkErrors: boolean; \}, `Record`\<`string`, `any`\>\> | Enable experimental flags to gain access to new features. These flags are not guaranteed to be stable and may change drastically in between patch or minor versions. |
| `initialState?` | `Serializable`\<\{ actor: undefined \| \{ \[x: string]: unknown; sub: string; \}; factorVerificationAge: \[number, number]; organization: undefined \| OrganizationResource; orgId: undefined \| string; orgPermissions: undefined \| string\[]; orgRole: undefined \| string; orgSlug: undefined \| string; session: undefined \| SessionResource; sessionClaims: JwtPayload; sessionId: undefined \| string; sessionStatus: SessionStatusClaim; user: undefined \| UserResource; userId: undefined \| string; \}\> | Provide an initial state of the Clerk client during server-side rendering. You don't need to set this value yourself unless you're [developing an SDK](/docs/guides/development/sdk-development/overview). |
| `isSatellite?` | boolean \| (url: URL) => boolean | A boolean that indicates whether the application is a satellite application. |
| `localization?` | [`LocalizationResource`](/docs/guides/customizing-clerk/localization) | Optional object to localize your components. Will only affect Clerk Components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages. |
| `newSubscriptionRedirectUrl?` | null \| string | The URL to navigate to after the user completes the checkout and clicks the "Continue" button. |
| `nonce?` | `string` | This nonce value will be passed through to the `@clerk/clerk-js` script tag. Use it to implement a [strict-dynamic CSP](/docs/guides/secure/best-practices/csp-headers#implementing-a-strict-dynamic-csp). Requires the `dynamic` prop to also be set. |
| `proxyUrl?` | string \| (url: URL) => string \| (url: URL) => string | **Required for applications that run behind a reverse proxy**. The URL that Clerk will proxy requests to. Can be either a relative path (`/__clerk`) or a full URL (`https:///__clerk`). |
| `publishableKey` | `string` | The Clerk Publishable Key for your instance. This can be found on the [API keys](https://dashboard.clerk.com/last-active?path=api-keys) page in the Clerk Dashboard. |
| ~~`redirectUrl?`~~ | null \| string | **Deprecated.** Use `signInFallbackRedirectUrl`, `signInForceRedirectUrl`, `signUpFallbackRedirectUrl`, or `signUpForceRedirectUrl` instead. |
| `routerPush?` | (to: string, metadata?: \{ windowNavigate: (to: string \| URL) => void; \}) => unknown | A function which takes the destination path as an argument and performs a "push" navigation. |
| `routerReplace?` | (to: string, metadata?: \{ windowNavigate: (to: string \| URL) => void; \}) => unknown | A function which takes the destination path as an argument and performs a "replace" navigation. |
| `sdkMetadata?` | \{ environment?: string; name: string; version: string; \} | Contains information about the SDK that the host application is using. You don't need to set this value yourself unless you're [developing an SDK](/docs/guides/development/sdk-development/overview). |
| `sdkMetadata.environment?` | `string` | Typically this will be the `NODE_ENV` that the SDK is currently running in. |
| `sdkMetadata.name` | `string` | The npm package name of the SDK. |
| `sdkMetadata.version` | `string` | The npm package version of the SDK. |
| `selectInitialSession?` | (client: ClientResource) => null \| SignedInSessionResource | By default, the last signed-in session is used during client initialization. This option allows you to override that behavior, e.g. by selecting a specific session. |
| `signInFallbackRedirectUrl?` | null \| string | The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. It's recommended to use the [environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead. Defaults to `'/'`. |
| `signInForceRedirectUrl?` | null \| string | This URL will always be redirected to after the user signs in. It's recommended to use the [environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead. |
| `signInUrl?` | `string` | This URL will be used for any redirects that might happen and needs to point to your primary application on the client-side. This option is optional for production instances. **It is required to be set for a satellite application in a development instance**. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead. |
| `signUpFallbackRedirectUrl?` | null \| string | The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. It's recommended to use the [environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead. Defaults to `'/'`. |
| `signUpForceRedirectUrl?` | null \| string | This URL will always be redirected to after the user signs up. It's recommended to use the [environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead. |
| `signUpUrl?` | `string` | This URL will be used for any redirects that might happen and needs to point to your primary application on the client-side. This option is optional for production instances but **must be set for a satellite application in a development instance**. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead. |
| `standardBrowser?` | `boolean` | By default, ClerkJS is loaded with the assumption that cookies can be set (browser setup). On native platforms this value must be set to `false`. |
| `supportEmail?` | `string` | Optional support email for display in authentication screens. Will only affect Clerk Components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages. |
| `taskUrls?` | `Record`\<`"choose-organization"`, `string`\> | Customize the URL paths users are redirected to after sign-in or sign-up when specific session tasks need to be completed. When `undefined`, it uses Clerk's default task flow URLs. Defaults to `undefined`. |
| `telemetry?` | false \| \{ debug?: boolean; disabled?: boolean; perEventSampling?: boolean; \} | Controls whether or not Clerk will collect [telemetry data](/docs/guides/how-clerk-works/security/clerk-telemetry). If set to `debug`, telemetry events are only logged to the console and not sent to Clerk. |
| `touchSession?` | `boolean` | By default, the [Clerk Frontend API `touch` endpoint](/docs/reference/frontend-api/tag/Sessions#operation/touchSession) is called during page focus to keep the last active session alive. This option allows you to disable this behavior. |
| `waitlistUrl?` | `string` | The full URL or path to the waitlist page. If `undefined`, will redirect to the [Account Portal waitlist page](/docs/guides/customizing-clerk/account-portal#waitlist). |
## SDK-specific properties
### Next.js
* `dynamic`
* `boolean`
Indicates whether or not Clerk should make dynamic auth data available based on the current request. Defaults to `false`. Opts the application into dynamic rendering when `true`. For more information, see Next.js rendering modes and Clerk.
### Chrome Extension
* `syncHost`
* `string`
To enable, pass the URL of the web application that the extension will sync the authentication state from. See the dedicated guide for more information.
---
title: Component Reference
description: A list of Clerk's comprehensive suite of components designed to
seamlessly integrate authentication and multi-tenancy into your application.
sdk: react, nextjs, js-frontend, chrome-extension, expo, android, expressjs,
fastify, react-router, remix, tanstack-react-start, go, astro, nuxt, vue,
ruby, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/overview
lastUpdated: 2025-11-21T23:29:30.000Z
availableSdks: react,nextjs,js-frontend,chrome-extension,expo,android,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
notAvailableSdks: ios
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/overview.mdx
---
Clerk offers a comprehensive suite of components designed to seamlessly integrate authentication and multi-tenancy into your application. With Clerk components, you can easily customize the appearance of authentication components and pages, manage the entire authentication flow to suit your specific needs, and even build robust SaaS applications.
## Authentication components
* \
* \
* \
* \
* \
## User components
* \
* \
* \
## Organization components
* \
* \
* \
* \
## Billing components
* \
* \
* \
* \
## Control components
Control components manage authentication-related behaviors in your application. They handle tasks such as controlling content visibility based on user authentication status, managing loading states during authentication processes, and redirecting users to appropriate pages. Control components render at `` and `` states for assertions on the Clerk object. A common example is the \ component, which allows you to conditionally render content only when a user is authenticated.
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
## Unstyled components
* \
* \
* \
* \
## Customization guides
* [Customize components with the `appearance` prop](/docs/guides/customizing-clerk/appearance-prop/overview)
* [Localize components with the `localization` prop (experimental)](/docs/guides/customizing-clerk/localization)
* [Add pages to the `` component](/docs/guides/customizing-clerk/adding-items/user-profile)
* [Add pages to the `` component](/docs/guides/customizing-clerk/adding-items/organization-profile)
### Secured by Clerk branding
> \[!WARNING]
> This feature requires a [paid plan](/pricing){{ target: '_blank' }} for production use, but all features are free to use in development mode so that you can try out what works for you. See the [pricing](/pricing){{ target: '_blank' }} page for more information.
By default, Clerk displays a **Secured by Clerk** badge on Clerk components. You can remove this branding by following these steps:
1. In the Clerk Dashboard, navigate to your application's [**Settings**](https://dashboard.clerk.com/~/settings).
2. Under **Branding**, toggle on the **Remove "Secured by Clerk" branding** option.
* [Join our Discord](https://clerk.com/discord "Join Discord")
* Join our official Discord server to chat with us directly and become a part of the Clerk community.
* {}
***
* [Need help?](/support "Get help")
* Contact us through Discord, Twitter, or email to receive answers to your questions and learn more about Clerk.
* {}
---
title: "`` component"
description: Clerk's component renders a UI for authenticating
users with Google's One Tap API.
sdk: astro, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/authentication/google-one-tap
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: chrome-extension,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/authentication/google-one-tap.mdx
---
> \[!IMPORTANT]
> To use Google One Tap with Clerk, you must [enable Google as a social connection in the Clerk Dashboard](/docs/guides/configure/auth-strategies/social-connections/google#configure-for-your-production-instance) and make sure to use custom credentials.
The `` component renders the [Google One Tap](https://developers.google.com/identity/gsi/web/guides/features) UI so that users can use a single button to sign-up or sign-in to your Clerk application with their Google accounts.
By default, this component will redirect users back to the page where the authentication flow started. However, you can override this with force redirect URL props or [force redirect URL environment variables](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects).
> \[!TIP]
> `` does not render if the user is already signed into your Clerk application, so there's no need to manually check if a user is signed in yourself before rendering it.
## Example
The following example includes basic implementation of the `` component. You can use this as a starting point for your own implementation.
```tsx {{ filename: 'app/routes/sign-in.tsx' }}
import { GoogleOneTap } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/sign-in')({
component: SignIn,
})
function SignIn() {
return
}
```
## Properties
* `cancelOnTapOutside?`
* `boolean`
If `true`, the One Tap prompt closes automatically if the user clicks outside of the prompt. Defaults to `true`.
***
* `itpSupport?`
* `boolean`
If `true`, enables the [ITP-specific UX](https://developers.google.com/identity/gsi/web/guides/itp) when One Tap is rendered on ITP browsers such as Chrome on iOS, Safari, and FireFox. Defaults to `true`.
***
* `fedCmSupport?`
* `boolean`
If `true`, enables Google One Tap to use [the FedCM API](https://developers.google.com/privacy-sandbox/3pcd/fedcm) to sign users in. See Google's docs on [best practices when disabling FedCM support](https://developers.google.com/identity/gsi/web/guides/display-google-one-tap#do_not_cover_google_one_tap). Defaults to `true`
***
* `signInForceRedirectUrl?`
* `string`
Useful if you want to redirect to a path specific to Google One Tap users. If provided, this URL will **always** be redirected to after the user signs in, overriding any \ redirect URL props or [redirect URL environment variables](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects).
***
* `signUpForceRedirectUrl?`
* `string`
Useful if you want to redirect to a path specific to Google One Tap users. If provided, this URL will **always** be redirected to after the user signs up, overriding any \ redirect URL props or [redirect URL environment variables](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects).
## Limitations
* If your application will use the Google API on behalf of your users, the `` component is not recommended, as Google does not provide Clerk with an access or refresh token that you can use.
* Users with the 1Password browser extension may not be able to render the Google One Tap UI. They must disable this extension.
* When testing in development, if you select the `X` button to close the Google One Tap UI, you may encounter [a cooldown](https://developers.google.com/identity/gsi/web/guides/features#exponential_cooldown) that prevents you from rendering it again for a period of time. To bypass the cooldown, remove the `g_state` cookie.
---
title: "`` component"
description: Clerk's component renders a UI for signing in users.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/authentication/sign-in
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/authentication/sign-in.mdx
---
{{ style: { maxWidth: '460px' } }}
The `` component renders a UI to allow users to sign in or sign up by default. The functionality of the `` component is controlled by the instance settings you specify in the [Clerk Dashboard](https://dashboard.clerk.com), such as [sign-in and sign-up options](/docs/guides/configure/auth-strategies/sign-up-sign-in-options) and [social connections](/docs/guides/configure/auth-strategies/social-connections/all-providers). You can further customize your `` component by passing additional properties at the time of rendering.
> \[!NOTE]
> The `` and `` components cannot render when a user is already signed in, unless the application allows multiple sessions. If a user is already signed in and the application only allows a single session, Clerk will redirect the user to the Home URL instead.
## Example
The following example includes basic implementation of the `` component. You can use this as a starting point for your own implementation.
If you would like to create a dedicated `/sign-in` page in your TanStack React Start application, there are a few requirements you must follow. See the [dedicated guide](/docs/tanstack-react-start/guides/development/custom-sign-in-or-up-page) for more information.
```tsx {{ filename: 'app/routes/sign-in.$.tsx' }}
import { SignIn } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/sign-in')({
component: SignInPage,
})
function SignInPage() {
return
}
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `fallbackRedirectUrl`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `forceRedirectUrl`
* `string`
If provided, this URL will always be redirected to after the user signs in. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `initialValues`
* SignInInitialValues
The values used to prefill the sign-in fields with.
***
* `oauthFlow`
* `"redirect" | "popup" | "auto"`
Determines how OAuth authentication is performed. Accepts the following properties:
* `"redirect"`: Redirect to the OAuth provider on the current page.
* `"popup"`: Open a popup window.
* `"auto"`: Choose the best method based on whether the current domain typically requires the `"popup"` flow to correctly perform authentication.
Defaults to `"auto"`.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash-based routing. For example: `/sign-in`.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
***
* `signUpFallbackRedirectUrl`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Used for the 'Don't have an account? Sign up' link that's rendered. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpForceRedirectUrl`
* `string`
If provided, this URL will always used as the redirect destination after the user signs up. Used for the 'Don't have an account? Sign up' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpUrl`
* `string`
The full URL or path to the sign-up page. Used for the 'Don't have an account? Sign up' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `transferable`
* `boolean`
Indicates whether or not sign in attempts are transferable to the sign up flow. Defaults to `true`. When set to `false`, prevents opaque sign ups when a user attempts to sign in via OAuth with an email that doesn't exist.
***
* `waitlistUrl`
* `string`
Full URL or path to the waitlist page. Use this property to provide the target of the 'Waitlist' link that's rendered. If `undefined`, will redirect to the [Account Portal waitlist page](/docs/guides/customizing-clerk/account-portal#waitlist). If you've passed the `waitlistUrl` prop to the \ component, it will infer from that, and you can omit this prop.
***
* `withSignUp`
* `boolean`
Opt into sign-in-or-up flow by setting this prop to `true`. When `true`, if a user does not exist, they will be prompted to sign up. If a user exists, they will be prompted to sign in. Defaults to `true` if the `CLERK_SIGN_IN_URL` environment variable is set. Otherwise, defaults to `false`.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
If Clerk's prebuilt components don't meet your specific needs or if you require more control over the logic, you can rebuild the existing Clerk flows using the Clerk API. For more information, see the [custom flow guides](/docs/guides/development/custom-flows/overview).
---
title: "`` component"
description: Clerk's component renders a UI for signing up users.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/authentication/sign-up
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/authentication/sign-up.mdx
---
{{ style: { maxWidth: '460px' } }}
The `` component renders a UI for signing up users. The functionality of the `` component is controlled by the instance settings you specify in the [Clerk Dashboard](https://dashboard.clerk.com), such as [sign-in and sign-up options](/docs/guides/configure/auth-strategies/sign-up-sign-in-options) and [social connections](/docs/guides/configure/auth-strategies/social-connections/all-providers). You can further customize your `` component by passing additional properties at the time of rendering.
> \[!NOTE]
> The `` and `` components cannot render when a user is already signed in, unless the application allows multiple sessions. If a user is already signed in and the application only allows a single session, Clerk will redirect the user to the Home URL instead.
## Example
The following example includes basic implementation of the `` component. You can use this as a starting point for your own implementation.
If you would like to create a dedicated `/sign-up` page in your Tanstack React Start application, there are a few requirements you must follow. See the [dedicated guide](/docs/tanstack-react-start/guides/development/custom-sign-up-page) for more information.
```tsx {{ filename: 'app/routes/sign-up.$.tsx' }}
import { SignUp } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/sign-up')({
component: SignUpPage,
})
function SignUpPage() {
return
}
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `fallbackRedirectUrl`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `forceRedirectUrl`
* `string`
If provided, this URL will always be used as the redirect destination after the user signs up. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `initialValues`
* SignUpInitialValues
The values used to prefill the sign-up fields with.
***
* `oauthFlow`
* `"redirect" | "popup" | "auto"`
Determines how OAuth authentication is performed. Accepts the following properties:
* `"redirect"`: Redirect to the OAuth provider on the current page.
* `"popup"`: Open a popup window.
* `"auto"`: Choose the best method based on whether the current domain typically requires the `"popup"` flow to correctly perform authentication.
Defaults to `"auto"`.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash-based routing. For example: `/sign-up`.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
***
* `signInFallbackRedirectUrl`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Used for the 'Already have an account? Sign in' link that's rendered. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signInForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs in. Used for the 'Already have an account? Sign in' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signInUrl`
* `string`
The full URL or path to the sign-in page. Used for the 'Already have an account? Sign in' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `unsafeMetadata`
* SignUpUnsafeMetadata
Metadata that can be read and set from the frontend and the backend. Once the sign-up is complete, the value of this field will be automatically copied to the created user's unsafe metadata (`User.unsafeMetadata`). One common use case is to collect custom information about the user during the sign-up process and store it in this property. Read more about [unsafe metadata](/docs/guides/users/extending#unsafe-metadata).
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
If Clerk's prebuilt components don't meet your specific needs or if you require more control over the logic, you can rebuild the existing Clerk flows using the Clerk API. For more information, see the [custom flow guides](/docs/guides/development/custom-flows/overview).
---
title: "`` component"
description: The component renders a waitlist form that allows
users to join for early access to your application.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/authentication/waitlist
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/authentication/waitlist.mdx
---
{{ style: { maxWidth: '460px' } }}
In **Waitlist** mode, users can register their interest in your app by joining a waitlist. This mode is ideal for apps in early development stages or those wanting to generate interest before launch. [Learn more about additional features available in **Waitlist** mode](/docs/guides/secure/restricting-access#waitlist).
The `` component renders a form that allows users to join for early access to your app.
## Enable Waitlist mode
Before using the `` component, you must enable **Waitlist** mode in the Clerk Dashboard:
1. In the Clerk Dashboard, navigate to the [**Restrictions**](https://dashboard.clerk.com/~/user-authentication/restrictions) page.
2. Under the **Sign-up modes** section, enable **Waitlist**.
## Example
> \[!WARNING]
> Before using the `` component, you must provide the `waitlistUrl` prop either in the \ or \ component to ensure proper functionality.
The following example includes a basic implementation of the `` component. You can use this as a starting point for your own implementation.
```tsx {{ filename: 'app/routes/waitlist.tsx' }}
import { Waitlist } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/waitlist')({
component: WaitlistPage,
})
function WaitlistPage() {
return
}
```
## Properties
All props are optional.
* `afterJoinWaitlistUrl`
* `string`
The full URL or path to navigate to after joining the waitlist.
***
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `signInUrl`
* `string`
The full URL or path to the sign in page. Used for the 'Already have an account? Sign in' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
## Customization
To learn about how to customize Clerk components, see the [customization guide](/docs/guides/customizing-clerk/appearance-prop/overview).
---
title: "`` component"
description: Clerk's component renders a UI for
resolving the `choose-organization` task.
sdk: js-frontend, nextjs, react, react-router, remix, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/authentication/task-choose-organization
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: js-frontend,nextjs,react,react-router,remix,tanstack-react-start
notAvailableSdks: chrome-extension,expo,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/authentication/task-choose-organization.mdx
---
{{ style: { maxWidth: '460px' } }}
The `` component renders a UI for resolving the `choose-organization` session task. The functionality of the `` component is controlled by the instance settings you specify in the [Clerk Dashboard](https://dashboard.clerk.com), such as [sign-in and sign-up options](/docs/guides/configure/auth-strategies/sign-up-sign-in-options) and [social connections](/docs/guides/configure/auth-strategies/social-connections/overview). You can further customize your `` component by passing additional properties at the time of rendering.
> \[!IMPORTANT]
> The `` component cannot render when a user doesn't have current session tasks.
## Example
The following example demonstrates how to host the `` component on a custom page.
> \[!NOTE]
> To see the full `__root.tsx` setup you need for Clerk with TanStack React Start, see the [TanStack React Start quickstart](/docs/tanstack-react-start/getting-started/quickstart).
```tsx {{ filename: 'src/routes/__root.tsx', mark: [7] }}
import * as React from 'react'
import { HeadContent, Scripts } from '@tanstack/react-router'
import { ClerkProvider } from '@clerk/tanstack-react-start'
function RootDocument({ children }: { children: React.ReactNode }) {
return (
{children}
)
}
```
The `` component must be used in conjunction with the `` component. See the [dedicated guide on how to self-host the `` component](/docs/tanstack-react-start/guides/development/custom-sign-in-or-up-page).
```tsx {{ filename: 'src/routes/onboarding/choose-organization.tsx' }}
import { TaskChooseOrganization } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/onboarding/choose-organization')({
component: ChooseOrganizationPage,
})
function ChooseOrganizationPage() {
return
}
```
## Properties
All props are optional.
* `redirectUrlComplete`
* `string`
The full URL or path to navigate to after successfully completing all tasks.
***
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
If Clerk's prebuilt components don't meet your specific needs or if you require more control over the logic, you can rebuild the existing Clerk flows using the Clerk API. For more information, see the [custom flow guides](/docs/guides/development/custom-flows/overview).
---
title: "``"
description: Clerk's component displays a table of Plans and
Features that users can subscribe to.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/billing/pricing-table
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/billing/pricing-table.mdx
---

The `` component displays a table of Plans and Features that users can subscribe to.
## Example
The following example includes a basic implementation of the `` component. You can use this as a starting point for your own implementation.
```tsx {{ filename: 'app/routes/pricing.tsx' }}
import { PricingTable } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/pricing')({
component: PricingPage,
})
function PricingPage() {
return
}
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `checkoutProps`
* `{ appearance: Appearance }`
Options for the checkout drawer. Accepts the following properties:
* [`appearance`](/docs/guides/customizing-clerk/appearance-prop/overview): an object used to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `collapseFeatures`
* `boolean`
A boolean that indicates whether the Features are collapsed. **Requires `layout` to be set to `'default'`**. Defaults to `false`.
***
* `ctaPosition`
* `'top' | 'bottom'`
The placement of the CTA button. **Requires `layout` to be set to `'default'`**. Defaults to `'bottom'`.
***
* `fallback`
* `JSX`
An optional UI to show when the pricing table is loading.
***
* `for`
* `'user' | 'organization'`
A string that indicates whether the pricing table is for users or [Organizations](/docs/guides/organizations/overview). If `'user'`, the pricing table will display a list of Plans and Features that **users** can subscribe to. If `'organization'`, the pricing table will display a list of Plans and Features that **Organizations** can subscribe to. Defaults to `'user'`.
***
* `newSubscriptionRedirectUrl`
* `string`
The URL to navigate to after the user completes the checkout and selects the "Continue" button.
---
title: \RedirectCallback />
description: Clerk's `` component is used to
implement custom OAuth flows. It handles the OAuth callback and completes the
authentication process.
sdk: astro, chrome-extension, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/authenticate-with-redirect-callback
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: expo,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/control/authenticate-with-redirect-callback.mdx
---
The `` component is a crucial part of implementing custom OAuth flows in your application. It serves as the callback handler for the authentication process initiated by the `authenticateWithRedirect()` method. Render it on the route specified as the `redirectUrl` in your `authenticateWithRedirect()` call.
This component automatically handles the OAuth callback, completing the authentication process and managing the user's session. It uses the handleRedirectCallback() method under the hood.
## Example
For an example of how to use the `` component, see the [custom flow](/docs/guides/development/custom-flows/authentication/oauth-connections) guide.
## Properties
All props are optional.
* `continueSignUpUrl?`
* `string | undefined | null`
The full URL or path to navigate to if the sign up requires additional information.
***
* `signInUrl?`
* `string`
The full URL or path where the `` component is mounted.
***
* `signUpUrl?`
* `string`
The full URL or path where the `` component is mounted.
***
* `signInFallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpFallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signInForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs in. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs up. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `firstFactorUrl?`
* `string | undefined`
The full URL or path to navigate to during sign in, if first factor verification is required.
***
* `secondFactorUrl?`
* `string | undefined`
The full URL or path to navigate to during sign in, if [multi-factor authentication](/docs/guides/configure/auth-strategies/sign-up-sign-in-options#multi-factor-authentication) is enabled.
***
* `resetPasswordUrl?`
* `string`
The full URL or path to navigate to during sign in, if the user is required to reset their password.
***
* `transferable?`
* `boolean`
A boolean that indicates whether or not sign in attempts are transferable to the sign up flow. Defaults to `true`. When set to `false`, prevents opaque sign ups when a user attempts to sign in via OAuth with an email that doesn't exist.
***
* `verifyEmailAddressUrl?`
* `string | undefined | null`
The full URL or path to navigate to after requesting email verification.
***
* `verifyPhoneNumberUrl?`
* `string | undefined | null`
The full URL or path to navigate to after requesting phone verification.
---
title: "``"
description: The component indicates that Clerk is partially operational.
sdk: nextjs, react, react-router, chrome-extension, remix, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/clerk-degraded
lastUpdated: 2025-11-21T22:25:46.000Z
availableSdks: nextjs,react,react-router,chrome-extension,remix,tanstack-react-start
notAvailableSdks: js-frontend,expo,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/control/clerk-degraded.mdx
---
The `` component indicates that Clerk is partially operational.
## Example
It's not recommended to wrap the entire app in control components; instead, only wrap the components that need access to the `Clerk` object, such as custom flowsA **custom flow** refers to a user interface built entirely from scratch using the Clerk API. Learn more about [custom flows](/docs/guides/development/custom-flows/overview)..
```tsx {{ filename: 'app/routes/index.tsx' }}
import { ClerkLoading, ClerkLoaded, ClerkDegraded, ClerkFailed } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
function Home() {
return (
<>
Clerk is loading...
Clerk has loaded (ready or degraded)
Clerk is experiencing issues. Please try again later.
Something went wrong with Clerk. Please contact support.
>
)
}
```
---
title: "``"
description: The component indicates that the Clerk object has failed to load.
sdk: nextjs, react, react-router, chrome-extension, remix, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/clerk-failed
lastUpdated: 2025-11-21T22:25:46.000Z
availableSdks: nextjs,react,react-router,chrome-extension,remix,tanstack-react-start
notAvailableSdks: js-frontend,expo,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/control/clerk-failed.mdx
---
The `` component indicates that the Clerk object has failed to load. This is useful for displaying an error message to the user.
## Example
It's not recommended to wrap the entire app in control components; instead, only wrap the components that need access to the `Clerk` object, such as custom flowsA **custom flow** refers to a user interface built entirely from scratch using the Clerk API. Learn more about [custom flows](/docs/guides/development/custom-flows/overview)..
```tsx {{ filename: 'app/routes/index.tsx' }}
import { ClerkLoading, ClerkLoaded, ClerkDegraded, ClerkFailed } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
function Home() {
return (
<>
Clerk is loading...
Clerk has loaded (ready or degraded)
Clerk is experiencing issues. Please try again later.
Something went wrong with Clerk. Please contact support.
>
)
}
```
---
title: "``"
description: The Protect component protects content or even entire routes based
on authentication, and optionally, authorization. It only renders its children
when the current user is signed-in, and if performing authorization checks, if
the user has been granted a specific type of access control (Role, Permission,
Feature, or Plan).
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/protect
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/control/protect.mdx
---
The \ component protects content or even entire routes based on:
* authentication: whether the user is signed-in or not.
* authorization: whether the user has been granted a specific type of access control (Role, Permission, Feature, or Plan)
`` **always** performs authentication checks. To perform authorization checksAuthorization checks are checks you perform in your code to determine the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions or access certain content. Learn more about [authorization checks](/docs/guides/secure/authorization-checks)., you can pass different props, like `role`, `permission`, `feature`, or `plan`.
`` accepts a `fallback` prop that will be rendered if the user fails the authentication or authorization checks.
`` can be used both client-side and server-side (in Server Components).
> \[!CAUTION]
> This component only **visually hides** its children when the current user is not authorized. The contents of its children remain accessible via the browser's source code even if the user fails the authorization check. Do not use this component to hide sensitive information that should be completely inaccessible to unauthorized users. For truly sensitive data, perform authorization checksAuthorization checks are checks you perform in your code to determine the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions or access certain content. Learn more about [authorization checks](/docs/guides/secure/authorization-checks). on the server before sending the data to the client.
## Usage
### Authentication checks
`` always performs authentication checks. It will render its children if the user is signed-in, and its `fallback` prop if the user is signed-out.
```tsx {{ filename: 'app/routes/dashboard.tsx' }}
import { Protect } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/dashboard')({
component: DashboardPage,
})
function DashboardPage() {
return (
Users that are signed-out can see this.}>
Users that are signed-in can see this.
)
}
```
### Authorization checks
To limit who is able to see the content that `` renders, you can pass **one** of the access control props: `permission`, `role`, `feature`, or `plan`. It's recommended to use **Permission-based** authorization over **Role-based** authorization, and **Feature-based** authorization over **Plan-based** authorization, as they are more flexible, easier to manage, and more secure.
If you do not pass any of the access control props, `` will render its children if the user is signed in, regardless of their Role or its Permissions.
For more complex authorization logic, pass conditional logic to the `condition` prop.
### Render content by Permissions
The following example demonstrates how to use the `` component to protect content by checking if the user has the `org:invoices:create` Permission.
```tsx {{ filename: 'app/routes/invoices.tsx' }}
import { Protect } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/invoices')({
component: InvoicesPage,
})
function InvoicesPage() {
return (
You do not have the Permissions to create an invoice.}
>
Users with Permission org:invoices:create can see this.
)
}
```
### Render content by Role
While authorization by `permission` is **recommended**, for convenience, `` allows a `role` prop to be passed.
The following example demonstrates how to use the `` component to protect content by checking if the user has the `org:billing` Role.
```tsx {{ filename: 'app/routes/billing.tsx' }}
import { Protect } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/billing')({
component: BillingPage,
})
function BillingPage() {
return (
Only a member of the Billing department can access this content.}
>
Users with Role org:billing can see this.
)
}
```
### Render content by Plan
The following example demonstrates how to use `` to protect content by checking if the user has a Plan.
```tsx {{ filename: 'app/routes/bronze.tsx' }}
import { Protect } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/bronze')({
component: BronzePage,
})
function BronzePage() {
return (
Sorry, only subscribers to the Bronze plan can access this content.}
>
Welcome, Bronze subscriber!
)
}
```
### Render content by Feature
The following example demonstrates how to use `` to protect content by checking if the user has a Feature.
```tsx {{ filename: 'app/routes/premium-access.tsx' }}
import { Protect } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/premium-access')({
component: PremiumAccessPage,
})
function PremiumAccessPage() {
return (
Sorry, only subscribers with the Premium Access feature can access this content.
}
>
Congratulations! You have access to the Premium Access feature.
)
}
```
### Render content conditionally
The following example uses ``'s `condition` prop to conditionally render its children if the user has the correct Role.
```tsx {{ filename: 'app/routes/settings.tsx' }}
import { Protect } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/settings')({
component: SettingsPage,
})
function SettingsPage() {
return (
has({ role: 'org:admin' }) || has({ role: 'org:billing_manager' })}
fallback={
Only an Admin or Billing Manager can access this content.
}
>
The settings page.
)
}
```
## Properties
* `condition?`
* `has => boolean`
Optional conditional logic that renders the children if it returns `true`.
***
* `fallback?`
* `JSX`
Optional UI to show when a user doesn't have the correct type of access control to access the protected content.
***
* `feature?`
* `string`
Optional string corresponding to a [Feature](/docs/guides/billing/overview).
***
* `plan?`
* `string`
Optional string corresponding to a [Plan](/docs/guides/billing/overview).
***
* `permission?`
* `string`
Optional string corresponding to a [Permission](/docs/guides/organizations/roles-and-permissions) in the format `org::`
***
* `role?`
* `string`
Optional string corresponding to a [Role](/docs/guides/organizations/roles-and-permissions) in the format `org:`
***
* `treatPendingAsSignedOut?`
* `boolean`
A boolean that indicates whether to treat pending sessions as signed out. Defaults to `true`.
---
title: "``"
description: The `` renders its children while Clerk is loading,
and is helpful for showing a custom loading state.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/clerk-loading
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/control/clerk-loading.mdx
---
The `` renders its children while Clerk is loading, and is helpful for showing a custom loading state.
## Example
It's not recommended to wrap the entire app in the `` component; instead, only wrap the components that need access to the `Clerk` object.
```tsx {{ filename: 'app/routes/index.tsx' }}
import { ClerkLoading, ClerkLoaded, ClerkDegraded, ClerkFailed } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
function Home() {
return (
<>
Clerk is loading...
Clerk has loaded (ready or degraded)
Clerk is experiencing issues. Please try again later.
Something went wrong with Clerk. Please contact support.
>
)
}
```
---
title: "``"
description: The `` component guarantees that the Clerk object has
loaded and will be available under `window.Clerk`. This allows you to wrap
child components to access the Clerk object without the need to check it
exists.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/clerk-loaded
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/control/clerk-loaded.mdx
---
The `` component guarantees that the Clerk object has loaded (the `status` is `'ready'` or `'degraded'`) and will be available under `window.Clerk`. This allows you to wrap child components to access the `Clerk` object without the need to check it exists.
## Example
It's not recommended to wrap the entire app in the `` component; instead, only wrap the components that need access to the `Clerk` object.
```tsx {{ filename: 'app/routes/index.tsx' }}
import { ClerkLoading, ClerkLoaded, ClerkDegraded, ClerkFailed } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
function Home() {
return (
<>
Clerk is loading...
Clerk has loaded (ready or degraded)
Clerk is experiencing issues. Please try again later.
Something went wrong with Clerk. Please contact support.
>
)
}
```
---
title: "`` (deprecated)"
description: The component will navigate to the
create Organization flow which has been configured in your application
instance. The behavior will be just like a server-side (3xx) redirect, and
will override the current location in the history stack.
sdk: nextjs, nuxt, react, react-router, remix, tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/redirect-to-create-organization
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/control/redirect-to-create-organization.mdx
---
> \[!WARNING]
> This feature is deprecated. Please use the redirectToCreateOrganization() method instead.
The `` component will navigate to the create Organization flow which has been configured in your application instance. The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.
## Example
```tsx {{ filename: 'app/routes/index.tsx' }}
import { SignedIn, SignedOut, RedirectToCreateOrganization } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
function Home() {
return (
You need to sign in to create an Organization.
)
}
```
---
title: "`` (deprecated)"
description: The component will navigate to
the Organization profile URL which has been configured in your application
instance. The behavior will be just like a server-side (3xx) redirect, and
will override the current location in the history stack.
sdk: nextjs, nuxt, react, react-router, remix, tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/redirect-to-organization-profile
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/control/redirect-to-organization-profile.mdx
---
> \[!WARNING]
> This feature is deprecated. Please use the redirectToOrganizationProfile() method instead.
The `` component will navigate to the Organization profile URL which has been configured in your application instance. The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.
## Example
```tsx {{ filename: 'app/routes/index.tsx' }}
import { SignedIn, SignedOut, RedirectToOrganizationProfile } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
function Home() {
return (
You need to sign in to view your Organization profile.
)
}
```
---
title: "``"
description: The component will navigate to the sign in URL
which has been configured in your application instance. The behavior will be
just like a server-side (3xx) redirect, and will override the current location
in the history stack.
sdk: chrome-extension, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/redirect-to-sign-in
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: chrome-extension,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,expo,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/control/redirect-to-sign-in.mdx
---
The `` component will navigate to the sign in URL which has been configured in your application instance. The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.
## Example
```tsx {{ filename: 'app/routes/index.tsx' }}
import { SignedIn, SignedOut, RedirectToSignIn, UserButton } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
function Home() {
return (
)
}
```
---
title: "``"
description: The component will navigate to the sign up URL
which has been configured in your application instance. The behavior will be
just like a server-side (3xx) redirect, and will override the current location
in the history stack.
sdk: chrome-extension, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/redirect-to-sign-up
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: chrome-extension,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,expo,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/control/redirect-to-sign-up.mdx
---
The `` component will navigate to the sign up URL which has been configured in your application instance. The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.
## Example
```tsx {{ filename: 'app/routes/index.tsx' }}
import { SignedIn, SignedOut, RedirectToSignUp, UserButton } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
function Home() {
return (
)
}
```
---
title: "`` (deprecated)"
description: The component will navigate to the user
profile URL which has been configured in your application instance. The
behavior will be just like a server-side (3xx) redirect, and will override the
current location in the history stack.
sdk: nextjs, nuxt, react, react-router, remix, tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/redirect-to-user-profile
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/control/redirect-to-user-profile.mdx
---
> \[!WARNING]
> This feature is deprecated. Please use the redirectToUserProfile() method instead.
The `` component will navigate to the Account Portal User Profile URL which has been configured in your application instance. The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.
To find your User Profile URL:
1. In the Clerk Dashboard, navigate to the [**Account Portal**](https://dashboard.clerk.com/~/account-portal) page.
2. Under **User profile**, select the **Visit** icon.
## Example
```tsx {{ filename: 'app/routes/index.tsx' }}
import { SignedIn, SignedOut, RedirectToUserProfile } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
function Home() {
return (
You need to sign in to view your user profile.
)
}
```
---
title: "``"
description: The component will navigate to the tasks flow
which has been configured in your application instance when users have pending
session tasks. The behavior will be just like a server-side (3xx) redirect,
and will override the current location in the history stack.
sdk: chrome-extension, nextjs, nuxt, react, react-router, tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/redirect-to-tasks
lastUpdated: 2025-11-21T22:25:46.000Z
availableSdks: chrome-extension,nextjs,nuxt,react,react-router,tanstack-react-start,vue
notAvailableSdks: js-frontend,expo,android,ios,expressjs,fastify,remix,go,astro,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/control/redirect-to-tasks.mdx
---
The `` component will navigate to the tasks flow which has been configured in your application instance when users have pending session tasks**Session tasks** are requirements that users must fulfill in order to complete the authentication process, such as choosing an Organization.. The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.
The `` component is primarily intended for use in custom flowsA **custom flow** refers to a user interface built entirely from scratch using the Clerk API. Learn more about [custom flows](/docs/guides/development/custom-flows/overview).. If you're using prebuilt components, you typically won't need to use `` as these components manage task redirection internally. [See the guide on handling session tasks outside of prebuilt components](/docs/guides/configure/session-tasks#redirecting-to-tasks).
## Example
```tsx {{ filename: 'app/routes/index.tsx' }}
import { SignedOut, RedirectToTasks } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
function Home() {
return (
)
}
```
---
title: "``"
description: Conditionally render content only when a user is signed in.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/signed-in
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/control/signed-in.mdx
---
## Overview
The `` component offers authentication checks as a cross-cutting concern. Any children components wrapped by a `` component will be rendered only if there's a user with an active session signed in your application.
> \[!CAUTION]
> This component only **visually hides** its children when the current user is not authenticated. The contents of its children remain accessible via the browser's source code even if the user fails the authentication check. Do not use this component to hide sensitive information that should be completely inaccessible to unauthorized users. For truly sensitive data, perform authorization checksAuthorization checks are checks you perform in your code to determine the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions or access certain content. Learn more about [authorization checks](/docs/guides/secure/authorization-checks). on the server before sending the data to the client.
## Example
```tsx {{ filename: 'app/routes/index.tsx' }}
import { SignedIn } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
function Home() {
return (
You are signed in.
This content is always visible.
)
}
```
## Properties
* `treatPendingAsSignedOut?`
* `boolean`
A boolean that indicates whether to treat pending sessions as signed out. Defaults to `true`.
---
title: "``"
description: Conditionally render content only when a user is signed out.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/signed-out
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/control/signed-out.mdx
---
The `` component offers authentication checks as a cross-cutting concern. Any child nodes wrapped by a `` component will be rendered only if there's no User signed in to your application.
## Example
```tsx {{ filename: 'app/routes/index.tsx' }}
import { SignedOut } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
function Home() {
return (
You are signed out.
This content is always visible.
)
}
```
## Properties
* `treatPendingAsSignedOut?`
* `boolean`
A boolean that indicates whether to treat pending sessions as signed out. Defaults to `true`.
---
title: "`` component"
description: Clerk's component is used to render an
Organization creation UI that allows users to create brand new Organizations
within your application.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/organization/create-organization
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/organization/create-organization.mdx
---
{{ style: { maxWidth: '492px' } }}
The `` component is used to render an Organization creation UI that allows users to create brand new Organizations in your application.
## Example
The following example includes a basic implementation of the `` component. You can use this as a starting point for your own implementation.
```tsx {{ filename: 'app/routes/create-organization.tsx' }}
import { CreateOrganization } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/create-organization')({
component: CreateOrganizationPage,
})
function CreateOrganizationPage() {
return
}
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `afterCreateOrganizationUrl`
* `string`
Full URL or path to navigate to after creating a new organization.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash-based routing. For example: `/create-organization`.
***
* `skipInvitationScreen`
* `boolean`
Hides the screen for sending invitations after an Organization is created. When left undefined, Clerk will automatically hide the screen if the number of max allowed members is equal to 1
***
* `hideSlug`
* `boolean`
Hides the optional slug field in the Organization creation screen.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
---
title: "`` component"
description: Clerk's component is used to render a
beautiful, full-featured Organization management UI that allows users to
manage their Organization profile and security settings.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/organization/organization-profile
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/organization/organization-profile.mdx
---

The `` component allows users to manage their Organization membership, security, and billing settings.
This component's **General** tab displays the Organization's information and the **Leave organization** button. Admins will be able to see the **Update profile** button, **Verified domains** section, and **Delete organization** button.
The **Members** tab shows the Organization's members along with their join dates and Roles. Admins will have the ability to invite a member, change a member's Role, or remove them from the Organization. Admins will have tabs within the **Members** tab to view the Organization's [invitations](/docs/guides/organizations/overview#organization-invitations) and [requests](/docs/guides/organizations/verified-domains#membership-requests).
The **Billing** tab displays the Plans and Features that are available to the Organization, as well as the user's billing information, such as their invoices and payment methods.
## Example
The `` component must be embedded using the [TanStack Router catch-all route](https://tanstack.com/router/latest/docs/framework/react/routing/routing-concepts#splat--catch-all-routes) in order for the routing to work.
```tsx {{ filename: 'app/routes/organization-profile.$.tsx' }}
import { OrganizationProfile } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/organization-profile/$')({
component: OrganizationProfilePage,
})
function OrganizationProfilePage() {
return
}
```
## Properties
The `` component accepts the following properties, all of which are **optional**:
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `afterLeaveOrganizationUrl`
* `string`
The full URL or path to navigate to after leaving an Organization.
***
* `customPages`
* `CustomPages[]`
An array of custom pages to add to the Organization profile. Only available for the JavaScript SDK. To add custom pages with React-based SDK's, see the [dedicated guide](/docs/guides/customizing-clerk/adding-items/organization-profile).
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash- and virtual-based routing. For example: `/organization-profile`.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
In addition, you also can add custom pages and links to the `` navigation sidenav. For more information, refer to the [Custom Pages](/docs/guides/customizing-clerk/adding-items/organization-profile) documentation.
---
title: "`` component"
description: Clerk's component is used to display
Organization related memberships, invitations, and suggestions for the user.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/organization/organization-list
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/organization/organization-list.mdx
---
{{ style: { maxWidth: '460px' } }}
The `` component displays Organization-related memberships and automatic [invitations](/docs/guides/organizations/verified-domains#automatic-invitations) and [suggestions](/docs/guides/organizations/verified-domains#automatic-suggestions) for the user.
## Example
```tsx {{ filename: 'app/routes/organizations.tsx' }}
import { OrganizationList } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/organizations')({
component: OrganizationListPage,
})
function OrganizationListPage() {
return (
`/organization/${org.slug}`}
afterSelectPersonalUrl={(user) => `/user/${user.id}`}
afterSelectOrganizationUrl={(org) => `/organization/${org.slug}`}
/>
)
}
```
## Properties
The `` component accepts the following properties, all of which are **optional**:
* `afterCreateOrganizationUrl`
* ((org: Organization) => string) | string
The full URL or path to navigate to after creating a new Organization.
***
* `afterSelectOrganizationUrl`
* ((org: Organization) => string) | string
The full URL or path to navigate to after selecting an Organization. Defaults to `undefined`.
***
* `afterSelectPersonalUrl`
* ((org: Organization) => string) | string
The full URL or path to navigate to after selecting the [Personal Account](/docs/guides/organizations/overview#allow-personal-accounts). Defaults to `undefined`.
***
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `hidePersonal`
* `boolean`
A boolean that controls whether `` will include the user's [Personal Account](/docs/guides/organizations/overview#allow-personal-accounts) in the Organization list. Setting this to `true` will hide the Personal Account option, and users will only be able to switch between Organizations. Defaults to `false`.
***
* `hideSlug`
* `boolean`
A boolean that controls whether the optional slug field in the Organization creation screen is hidden. Defaults to `false`.
***
* `skipInvitationScreen`
* `boolean | undefined`
A boolean that controls whether the screen for sending invitations after an Organization is created is hidden. When `undefined`, Clerk will automatically hide the screen if the number of max allowed members is equal to 1. Defaults to `false`.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
[org-ref]: /docs/reference/javascript/organization
---
title: "`` component"
description: Clerk's component is used to enable the
ability to switch between available Organizations the user may be part of in
your application.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/organization/organization-switcher
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/organization/organization-switcher.mdx
---
{{ style: { maxWidth: '436px' } }}
The `` component allows a user to switch between their joined Organizations. If [Personal Accounts are enabled](/docs/guides/organizations/overview#allow-personal-accounts), users can also switch to their Personal Account. This component is useful for applications that have a multi-tenant architecture, where users can be part of multiple Organizations. It handles all Organization-related flows, including full Organization management for admins. Learn more about [Organizations](/docs/guides/organizations/overview).
## Example
```tsx {{ filename: 'app/routes/organization-switcher.tsx' }}
import { OrganizationSwitcher } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/organization-switcher')({
component: OrganizationSwitcherPage,
})
function OrganizationSwitcherPage() {
return
}
```
## Properties
The `` component accepts the following properties, all of which are **optional**:
* `afterCreateOrganizationUrl`
* `string`
The full URL or path to navigate to after creating a new Organization.
***
* `afterLeaveOrganizationUrl`
* `string`
The full URL or path to navigate to after the user leaves the currently Active OrganizationA user can be a member of multiple Organizations, but only one can be active at a time. The **Active Organization** determines which Organization-specific data the user can access and which Role and related Permissions they have within the Organization..
***
* `afterSelectOrganizationUrl`
* `string`
The full URL or path to navigate to after a successful Organization switch.
***
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `createOrganizationMode`
* `'modal' | 'navigation'`
A boolean that controls whether clicking the "Create organization" button will cause the \ component to open as a modal, or if the browser will navigate to the `createOrganizationUrl` where `` is mounted as a page. Defaults to: `'modal'`.
***
* `createOrganizationUrl`
* `string`
The full URL or path where the ``]createorg-ref component is mounted.
***
* `defaultOpen`
* `boolean`
A boolean that controls the default state of the `` component.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `hidePersonal`
* `boolean`
A boolean that controls whether `` will include the user's [Personal Account](/docs/guides/organizations/overview#allow-personal-accounts) in the Organization list. Setting this to `true` will hide the Personal Account option, and users will only be able to switch between Organizations. Defaults to `false`.
***
* `hideSlug`
* `boolean`
A boolean that controls whether the optional slug field in the Organization creation screen is hidden.
***
* `organizationProfileMode`
* `'modal' | 'navigation'`
A boolean that controls whether clicking the **Manage organization** button will cause the \ component to open as a modal, or if the browser will navigate to the `organizationProfileUrl` where `` is mounted as a page. Defaults to: `'modal'`.
***
* `organizationProfileProps`
* `object`
Specify options for the underlying \ component. For example: `{appearance: {...}}`
***
* `organizationProfileUrl`
* `string`
The full URL or path where the \ component is mounted.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
[createorg-ref]: /docs/reference/components/organization/create-organization
[orgprofile-ref]: /docs/reference/components/organization/organization-profile
---
title: "``"
description: The component is a button that links to the sign-in
page or displays the sign-in modal.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/unstyled/sign-in-button
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/unstyled/sign-in-button.mdx
---
The `` component is a button that, by default, links to your app's sign-in page. Your sign-in page will be hosted by Clerk using the [Account Portal](/docs/guides/customizing-clerk/account-portal) unless you have set up a dedicated sign-in page.
## Usage
### Basic usage
```tsx {{ filename: 'app/routes/sign-in.tsx' }}
import { SignInButton } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/sign-in')({
component: SignIn,
})
function SignIn() {
return
}
```
### Custom usage
You can create a custom button by wrapping your own button, or button text, in the `` component.
```tsx {{ filename: 'app/routes/sign-in.tsx' }}
import { SignInButton } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/sign-in')({
component: SignIn,
})
function SignIn() {
return (
Custom sign in button
)
}
```
## Properties
* `forceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs in. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `fallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `oauthFlow`
* `"redirect" | "popup" | "auto"`
Determines how OAuth authentication is performed. Accepts the following properties:
* `"redirect"`: Redirect to the OAuth provider on the current page.
* `"popup"`: Open a popup window.
* `"auto"`: Choose the best method based on whether the current domain typically requires the `"popup"` flow to correctly perform authentication.
Defaults to `"auto"`.
***
* `signUpForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs up. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpFallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `mode?`
* `'redirect' | 'modal'`
Determines what happens when a user clicks on the ``. Setting this to `'redirect'` will redirect the user to the sign-in route. Setting this to `'modal'` will open a modal on the current route. Defaults to `'redirect'`.
***
* `children?`
* `React.ReactNode`
Children you want to wrap the `` in.
***
* `initialValues`
* SignInInitialValues
The values used to prefill the sign-in fields with.
---
title: "``"
description: The `` component is a button that signs a user out.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/unstyled/sign-out-button
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/unstyled/sign-out-button.mdx
---
The `` component is a button that signs a user out. By default, it is a `` tag that says **Sign Out**, but it is completely customizable by passing children.
## Usage
### Basic usage
```tsx {{ filename: 'app/routes/sign-out.tsx' }}
import { SignOutButton } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/sign-out')({
component: SignOut,
})
function SignOut() {
return
}
```
### Custom usage
You can create a custom button by wrapping your own button, or button text, in the `` component.
```tsx {{ filename: 'app/routes/index.tsx' }}
import { SignOutButton } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
function Home() {
return (
Custom sign out button
)
}
```
### Multi-session usage
#### Sign out of all sessions
Clicking the `` component signs the user out of all sessions. This is the default behavior.
#### Sign out of a specific session
You can sign out of a specific session by passing in a `sessionId` to the `sessionId` prop. This is useful for signing a single account out of a [multi-session application](/docs/guides/secure/session-options#multi-session-applications).
In the following example, the `sessionId` is retrieved from the useAuth() hook. If the user is not signed in, the `sessionId` will be `null`, and the user is shown the \ component. If the user is signed in, the user is shown the `` component, which when clicked, signs the user out of that specific session.
```tsx {{ filename: 'app/routes/index.tsx' }}
import { SignInButton, SignOutButton, useAuth } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
function Home() {
const { sessionId } = useAuth()
if (!sessionId) {
return
}
return
}
```
## Properties
* `redirectUrl?`
* `string`
The full URL or path to navigate after successful sign-out.
***
* `sessionId?`
* `string`
The ID of a specific session to sign out of. Useful for [multi-session applications](/docs/guides/secure/session-options#multi-session-applications).
***
* `children?`
* `React.ReactNode`
Children you want to wrap the `` in.
---
title: "``"
description: The `` component is used to complete a
one-click, cryptographically-secure sign-in flow using MetaMask.
sdk: expo, nextjs, nuxt, react, react-router, remix, tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/unstyled/sign-in-with-metamask
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,chrome-extension,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/unstyled/sign-in-with-metamask.mdx
---
The `` component is used to complete a one-click, cryptographically-secure sign-in flow using MetaMask.
## Usage
### Basic usage
```tsx {{ filename: 'app/routes/index.tsx' }}
import { SignInWithMetamaskButton } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
function Home() {
return
}
```
### Custom usage
In some cases, you will want to use your own button, or button text. You can do that by wrapping your button in the `` component.
```tsx {{ filename: 'app/routes/index.tsx' }}
import { SignInWithMetamaskButton } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
function Home() {
return (
Custom sign in button
)
}
```
---
title: "``"
description: The component is a button that links to the sign-up
page or displays the sign-up modal.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/unstyled/sign-up-button
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/unstyled/sign-up-button.mdx
---
The `` component is a button that, by default, links to your app's sign-up page. Your sign-up page will be hosted by Clerk using the [Account Portal](/docs/guides/customizing-clerk/account-portal) unless you have set up a dedicated sign-up page.
## Usage
### Basic usage
```tsx {{ filename: 'app/routes/sign-up.tsx' }}
import { SignUpButton } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/sign-up')({
component: SignUp,
})
function SignUp() {
return
}
```
### Custom usage
You can create a custom button by wrapping your own button, or button text, in the `` component.
```tsx {{ filename: 'app/routes/index.tsx' }}
import { SignUpButton } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
function Home() {
return (
Custom sign up button
)
}
```
## Properties
* `forceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs up. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `fallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `oauthFlow`
* `"redirect" | "popup" | "auto"`
Determines how OAuth authentication is performed. Accepts the following properties:
* `"redirect"`: Redirect to the OAuth provider on the current page.
* `"popup"`: Open a popup window.
* `"auto"`: Choose the best method based on whether the current domain typically requires the `"popup"` flow to correctly perform authentication.
Defaults to `"auto"`.
***
* `signInForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs in. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signInFallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `mode?`
* `'redirect' | 'modal'`
Determines what happens when a user clicks on the ``. Setting this to `'redirect'` will redirect the user to the sign-up route. Setting this to `'modal'` will open a modal on the current route. Defaults to `'redirect'`
***
* `children?`
* `React.ReactNode`
Children you want to wrap the `` in.
***
* `initialValues`
* SignUpInitialValues
The values used to prefill the sign-up fields with.
***
* `unsafeMetadata`
* SignUpUnsafeMetadata
Metadata that can be read and set from the frontend and the backend. Once the sign-up is complete, the value of this field will be automatically copied to the created user's unsafe metadata (`User.unsafeMetadata`). One common use case is to collect custom information about the user during the sign-up process and store it in this property. Read more about [unsafe metadata](/docs/guides/users/extending#unsafe-metadata).
---
title: "`` component"
description: Clerk's component is used to render the familiar
user button UI popularized by Google.
search:
rank: 1
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/user/user-button
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/user/user-button.mdx
---
{{ style: { maxWidth: '436px' } }}
The `` component renders the familiar user button UI popularized by Google. When selected, it opens a dropdown menu with options to manage account settings and sign out. The "Manage account" option launches the \ component, providing access to profile and security settings.
For users that have [multi-session](/docs/guides/secure/session-options#multi-session-applications) enabled, the `` also allows users to sign into multiple accounts at once and instantly switch between them without the need for a full page reload. Learn more [here](/docs/guides/secure/session-options#multi-session-applications).
## Example
In the following example, `` is mounted inside a header component, which is a common pattern on many websites and applications. When the user is signed in, they will see their avatar and be able to open the popup menu.
```tsx {{ filename: 'app/routes/index.tsx' }}
import { SignedIn, UserButton, SignInButton, SignedOut } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
function Home() {
return (
)
}
```
## Properties
The `` component accepts the following properties, all of which are **optional**:
* `afterMultiSessionSingleSignOutUrl` (deprecated)
* `string`
**Deprecated. Move `afterMultiSessionSingleSignOutUrl` to \.** The full URL or path to navigate to after signing out from a currently active account in a multi-session app.
***
* `afterSignOutUrl` (deprecated)
* `string`
**Deprecated. Move `afterSignOutUrl` to \.** The full URL or path to navigate to after a successful sign-out.
***
* `afterSwitchSessionUrl`
* `string`
The full URL or path to navigate to after a successful account change in a multi-session app.
***
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `defaultOpen`
* `boolean`
Controls whether the `` should open by default during the first render.
***
* `showName`
* `boolean`
Controls if the user name is displayed next to the user image button.
***
* `signInUrl`
* `string`
The full URL or path to navigate to when the **Add another account** button is clicked. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `userProfileMode`
* `'modal' | 'navigation'`
Controls whether selecting the **Manage your account** button will cause the \ component to open as a modal, or if the browser will navigate to the `userProfileUrl` where `` is mounted as a page. Defaults to: `'modal'`.
***
* `userProfileProps`
* `object`
Specify options for the underlying \ component. For example: `{additionalOAuthScopes: {google: ['foo', 'bar'], github: ['qux']}}`.
***
* `userProfileUrl`
* `string`
The full URL or path leading to the user management interface.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
You can also [add custom actions and links to the `` menu](/docs/guides/customizing-clerk/adding-items/user-button).
---
title: "`` component"
description: Clerk's component is used to render a beautiful,
full-featured account management UI that allows users to manage their profile
and security settings.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/user/user-profile
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/user/user-profile.mdx
---
{{ style: { maxWidth: '100%' } }}
The `` component is used to render a beautiful, full-featured account management UI that allows users to manage their profile, security, and billing settings.
## Example
The `` component must be embedded using the [TanStack Router catch-all route](https://tanstack.com/router/latest/docs/framework/react/routing/routing-concepts#splat--catch-all-routes) in order for the routing to work.
```tsx {{ filename: 'app/routes/user-profile.$.tsx' }}
import { UserProfile } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/user-profile/$')({
component: UserProfilePage,
})
function UserProfilePage() {
return
}
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash-based routing. For example: `/user-profile`.
***
* `additionalOAuthScopes`
* `object`
Specify additional scopes per OAuth provider that your users would like to provide if not already approved. For example: `{google: ['foo', 'bar'], github: ['qux']}`.
***
* `customPages`
* CustomPage\[]
An array of custom pages to add to the user profile. Only available for the JavaScript SDK. To add custom pages with React-based SDK's, see the [dedicated guide](/docs/guides/customizing-clerk/adding-items/user-profile).
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
In addition, you also can add custom pages and links to the `` navigation sidenav. For more information, refer to the [Custom Pages documentation](/docs/guides/customizing-clerk/adding-items/user-profile).
---
title: "`` component"
description: Clerk's component is used to render the familiar
user avatar on its own.
search:
rank: 1
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/user/user-avatar
lastUpdated: 2025-11-21T23:29:30.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/components/user/user-avatar.mdx
---

The `` component renders the authenticated user's avatar on its own, a common UI element found across many websites and applications.
## Example
In the following example, `` is mounted inside a header component, which is a common pattern on many websites and applications. When the user is signed in, they will see their avatar.
```tsx {{ filename: 'app/routes/index.tsx' }}
import { SignedIn, UserAvatar, SignInButton, SignedOut } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
function Home() {
return (
)
}
```
## Properties
The `` component accepts the following properties, all of which are **optional**:
* `rounded?`
* `boolean`
Determines whether the user avatar is displayed with rounded corners.
***
* `appearance?`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback?`
* `ReactNode`
Optional element to be rendered while the component is mounting.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
---
title: "`useOrganizationList()`"
description: Access and manage the current user's Organization list in your
React application with Clerk's useOrganizationList() hook.
sdk: chrome-extension, expo, nextjs, react, react-router, remix,
tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-organization-list
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: chrome-extension,expo,nextjs,react,react-router,remix,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/hooks/use-organization-list.mdx
---
The `useOrganizationList()` hook provides access to the current user's Organization memberships, invitations, and suggestions. It also includes methods for creating new Organizations and managing the Active OrganizationA user can be a member of multiple Organizations, but only one can be active at a time. The **Active Organization** determines which Organization-specific data the user can access and which Role and related Permissions they have within the Organization..
## Parameters
`useOrganizationList()` accepts a single object with the following properties:
| Property | Type | Description |
| ----------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `userInvitations?` | true \| \{ initialPage?: number; pageSize?: number; \} & \{ status?: "expired" \| "pending" \| "accepted" \| "revoked"; \} & \{ infinite?: boolean; keepPreviousData?: boolean; \} | If set to `true`, all default properties will be used. Otherwise, accepts an object with the following optional properties:
`status`: A string that filters the invitations by the provided status.
Any of the properties described in Shared properties.
|
| `userMemberships?` | true \| \{ initialPage?: number; pageSize?: number; \} & object & \{ infinite?: boolean; keepPreviousData?: boolean; \} | If set to `true`, all default properties will be used. Otherwise, accepts an object with the following optional properties:
Any of the properties described in Shared properties.
|
| `userSuggestions?` | true \| \{ initialPage?: number; pageSize?: number; \} & \{ status?: "pending" \| "accepted" \| ("pending" \| "accepted")\[]; \} & \{ infinite?: boolean; keepPreviousData?: boolean; \} | If set to `true`, all default properties will be used. Otherwise, accepts an object with the following optional properties:
`status`: A string that filters the suggestions by the provided status.
Any of the properties described in Shared properties.
|
> \[!WARNING]
> By default, the `userMemberships`, `userInvitations`, and `userSuggestions` attributes are not populated. To fetch and paginate the data, you must pass `true` or an object with the desired properties.
### Shared properties
Optional properties that are shared across the `userMemberships`, `userInvitations`, and `userSuggestions` properties.
| Property | Type | Description |
| --------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `initialPage?` | `number` | A number that specifies which page to fetch. For example, if `initialPage` is set to 10, it will skip the first 9 pages and fetch the 10th page. Defaults to `1`. |
| `pageSize?` | `number` | A number that specifies the maximum number of results to return per page. Defaults to `10`. |
| Name | Type | Description |
| ------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `infinite?` | `boolean` | If `true`, newly fetched data will be appended to the existing list rather than replacing it. Useful for implementing infinite scroll functionality. Defaults to `false`. |
| `keepPreviousData?` | `boolean` | If `true`, the previous data will be kept in the cache until new data is fetched. Defaults to `false`. |
## Returns
| Property | Type | Description |
| ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `createOrganization` | undefined \| (CreateOrganizationParams: CreateOrganizationParams) => Promise\<OrganizationResource\> | A function that returns a `Promise` which resolves to the newly created `Organization`. |
| `isLoaded` | `boolean` | A boolean that indicates whether Clerk has completed initialization and there is an authenticated user. Initially `false`, becomes `true` once Clerk loads with a user. |
| `setActive` | undefined \| (setActiveParams: SetActiveParams) => Promise\ | A function that sets the active session and/or organization. |
| `userInvitations` | PaginatedResourcesWithDefault\<UserOrganizationInvitationResource\> \| PaginatedResources\<UserOrganizationInvitationResource, T\["userInvitations"] *extends* \{ infinite: true; \} ? true : false\> | Returns `PaginatedResources` which includes a list of the user's organization invitations. |
| `userMemberships` | PaginatedResourcesWithDefault\<OrganizationMembershipResource\> \| PaginatedResources\<OrganizationMembershipResource, T\["userMemberships"] *extends* \{ infinite: true; \} ? true : false\> | Returns `PaginatedResources` which includes a list of the user's organization memberships. |
| `userSuggestions` | PaginatedResourcesWithDefault\<OrganizationSuggestionResource\> \| PaginatedResources\<OrganizationSuggestionResource, T\["userSuggestions"] *extends* \{ infinite: true; \} ? true : false\> | Returns `PaginatedResources` which includes a list of suggestions for organizations that the user can join. |
### `CreateOrganizationParams`
| Property | Type | Description |
| ------------------------- | -------- | ----------------------------- |
| `name` | `string` | The name of the organization. |
| `slug?` | `string` | The slug of the organization. |
### `PaginatedResources`
| Property | Type | Description |
| ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `count` | `number` | The total count of data that exist remotely. |
| `data` | T\[] | An array that contains the fetched data. For example, for the `memberships` attribute, data will be an array of OrganizationMembership objects. |
| `error` | null \| ClerkAPIResponseError | Clerk's API response error object. |
| `fetchNext` | () => void | A function that triggers the next page to be loaded. This is the same as `fetchPage(page => Math.min(pageCount, page + 1))`. |
| `fetchPage` | `ValueOrSetter`\<`number`\> | A function that triggers a specific page to be loaded. |
| `fetchPrevious` | () => void | A function that triggers the previous page to be loaded. This is the same as `fetchPage(page => Math.max(0, page - 1))`. |
| `hasNextPage` | `boolean` | A boolean that indicates if there are available pages to be fetched. |
| `hasPreviousPage` | `boolean` | A boolean that indicates if there are available pages to be fetched. |
| `isError` | `boolean` | A boolean that indicates the request failed. |
| `isFetching` | `boolean` | A boolean that is `true` if there is an ongoing request or a revalidation. |
| `isLoading` | `boolean` | A boolean that is `true` if there is an ongoing request and there is no fetched data. |
| `page` | `number` | The current page. |
| `pageCount` | `number` | The total amount of pages. It is calculated based on `count`, `initialPage`, and `pageSize`. |
| `revalidate` | () => Promise\ | A function that triggers a revalidation of the current page. |
| `setData` | `Infinite` *extends* `true` ? `CacheSetter`\<(undefined \| ClerkPaginatedResponse\)\[]\> : `CacheSetter`\<undefined \| ClerkPaginatedResponse\\> | A function that allows you to set the data manually. |
To see the different Organization features integrated into one application, take a look at our [Organizations demo repository](https://github.com/clerk/organizations-demo).
## Examples
### Expanding and paginating attributes
To keep network usage to a minimum, developers are required to opt-in by specifying which resource they need to fetch and paginate through. So by default, the `userMemberships`, `userInvitations`, and `userSuggestions` attributes are not populated. You must pass `true` or an object with the desired properties to fetch and paginate the data.
```jsx
// userMemberships.data will never be populated
const { userMemberships } = useOrganizationList()
// Use default values to fetch userMemberships, such as initialPage = 1 and pageSize = 10
const { userMemberships } = useOrganizationList({
userMemberships: true,
})
// Pass your own values to fetch userMemberships
const { userMemberships } = useOrganizationList({
userMemberships: {
pageSize: 20,
initialPage: 2, // skips the first page
},
})
// Aggregate pages in order to render an infinite list
const { userMemberships } = useOrganizationList({
userMemberships: {
infinite: true,
},
})
```
### Infinite pagination
The following example demonstrates how to use the `infinite` property to fetch and append new data to the existing list. The `userMemberships` attribute will be populated with the first page of the user's Organization memberships. When the "Load more" button is clicked, the `fetchNext` helper function will be called to append the next page of memberships to the list.
```tsx {{ filename: 'components/JoinedOrganizations.tsx' }}
import { useOrganizationList } from '@clerk/tanstack-react-start'
export function JoinedOrganizations() {
const { isLoaded, setActive, userMemberships } = useOrganizationList({
userMemberships: {
infinite: true,
},
})
// Handle loading state
if (!isLoaded) return
userMemberships.fetchNext()}>
Load more
>
)
}
```
### Simple pagination
The following example demonstrates how to use the `fetchPrevious` and `fetchNext` helper functions to paginate through the data. The `userInvitations` attribute will be populated with the first page of invitations. When the "Previous page" or "Next page" button is clicked, the `fetchPrevious` or `fetchNext` helper function will be called to fetch the previous or next page of invitations.
Notice the difference between this example's pagination and the infinite pagination example above.
```tsx {{ filename: 'components/UserInvitationsTable.tsx' }}
import { useOrganizationList } from '@clerk/tanstack-react-start'
export function UserInvitationsTable() {
const { isLoaded, userInvitations } = useOrganizationList({
userInvitations: {
infinite: true,
keepPreviousData: true,
},
})
// Handle loading state
if (!isLoaded || userInvitations.isLoading) return
Loading...
return (
<>
Email
Org name
{userInvitations.data?.map((inv) => (
{inv.emailAddress}
{inv.publicOrganizationData.name}
))}
Prev
Next
>
)
}
```
## Related guides
* [Build a custom Organization switcher](/docs/guides/development/custom-flows/organizations/organization-switcher)
* Use Clerk's API to build a custom flow for switching between Organizations
***
* [Create Organizations](/docs/guides/development/custom-flows/organizations/create-organizations)
* Use Clerk's API to build a custom flow for creating Organizations
***
* [Manage a user's Organization invitations](/docs/guides/development/custom-flows/organizations/manage-user-org-invitations)
* Use Clerk's API to build a custom flow for managing user's Organization invitations
---
title: useAuth()
description: Access and manage authentication state in your application with
Clerk's useAuth() hook.
sdk: astro, chrome-extension, expo, nextjs, react, react-router,
tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-auth
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,react,react-router,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,remix,go,nuxt,vue,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/hooks/use-auth.mdx
---
The `useAuth()` hook provides access to the current user's authentication state and methods to manage the active session.
> \[!NOTE]
> To access auth data server-side, see the Auth object reference doc.
## Parameters
| Parameter | Type | Description |
| ---------------------------- | -------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `initialAuthStateOrOptions?` | null \| Record\ \| \{ treatPendingAsSignedOut?: boolean; \} | An object containing the initial authentication state or options for the `useAuth()` hook. If not provided, the hook will attempt to derive the state from the context. `treatPendingAsSignedOut` is a boolean that indicates whether pending sessions are considered as signed out or not. Defaults to `true`. |
## Returns
There are multiple variants of this type available which you can select by clicking on one of the tabs.
| Name | Type | Description |
| ------ | ------ | ------ |
| `actor` | `undefined` | The JWT actor for the session. Holds identifier for the user that is impersonating the current user. Read more about [impersonation](/docs/guides/users/impersonation). |
| `getToken()` | (options?: GetTokenOptions) => Promise\ | A function that retrieves the current user's session token or a custom JWT template. Returns a promise that resolves to the token. See the reference doc. |
| `has` | `undefined` | A function that checks if the user has specific permissions or roles. See the reference doc. |
| `isLoaded` | `false` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `undefined` | A boolean that indicates whether a user is currently signed in. |
| `orgId` | `undefined` | The ID of the user's active organization. |
| `orgRole` | `undefined` | The current user's role in their active organization. |
| `orgSlug` | `undefined` | The URL-friendly identifier of the user's active organization. |
| `sessionClaims` | `undefined` | The current user's [session claims](/docs/guides/sessions/session-tokens). |
| `sessionId` | `undefined` | The ID for the current session. |
| `signOut()` | \{ (options?: SignOutOptions): Promise\; (signOutCallback?: SignOutCallback, options?: SignOutOptions): Promise\; \} | A function that signs out the current user. Returns a promise that resolves when complete. See the reference doc. |
| `userId` | `undefined` | The ID of the current user. |
| Name | Type | Description |
| ------ | ------ | ------ |
| `actor` | `null` | The JWT actor for the session. Holds identifier for the user that is impersonating the current user. Read more about [impersonation](/docs/guides/users/impersonation). |
| `getToken()` | (options?: GetTokenOptions) => Promise\ | A function that retrieves the current user's session token or a custom JWT template. Returns a promise that resolves to the token. See the reference doc. |
| `has()` | (params: CheckAuthorizationParamsWithCustomPermissions) => false | A function that checks if the user has specific permissions or roles. See the reference doc. |
| `isLoaded` | `true` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `false` | A boolean that indicates whether a user is currently signed in. |
| `orgId` | `null` | The ID of the user's active organization. |
| `orgRole` | `null` | The current user's role in their active organization. |
| `orgSlug` | `null` | The URL-friendly identifier of the user's active organization. |
| `sessionClaims` | `null` | The current user's [session claims](/docs/guides/sessions/session-tokens). |
| `sessionId` | `null` | The ID for the current session. |
| `signOut()` | \{ (options?: SignOutOptions): Promise\; (signOutCallback?: SignOutCallback, options?: SignOutOptions): Promise\; \} | A function that signs out the current user. Returns a promise that resolves when complete. See the reference doc. |
| `userId` | `null` | The ID of the current user. |
| Name | Type | Description |
| ------ | ------ | ------ |
| `actor` | null \| \{ \[x: string]: unknown; sub: string; \} | The JWT actor for the session. Holds identifier for the user that is impersonating the current user. Read more about [impersonation](/docs/guides/users/impersonation). |
| `getToken()` | (options?: GetTokenOptions) => Promise\ | A function that retrieves the current user's session token or a custom JWT template. Returns a promise that resolves to the token. See the reference doc. |
| `has()` | (isAuthorizedParams: CheckAuthorizationParamsWithCustomPermissions) => boolean | A function that checks if the user has specific permissions or roles. See the reference doc. |
| `isLoaded` | `true` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `true` | A boolean that indicates whether a user is currently signed in. |
| `orgId` | `null` | The ID of the user's active organization. |
| `orgRole` | `null` | The current user's role in their active organization. |
| `orgSlug` | `null` | The URL-friendly identifier of the user's active organization. |
| `sessionClaims` | `JwtPayload` | The current user's [session claims](/docs/guides/sessions/session-tokens). |
| `sessionId` | `string` | The ID for the current session. |
| `signOut()` | \{ (options?: SignOutOptions): Promise\; (signOutCallback?: SignOutCallback, options?: SignOutOptions): Promise\; \} | A function that signs out the current user. Returns a promise that resolves when complete. See the reference doc. |
| `userId` | `string` | The ID of the current user. |
| Name | Type | Description |
| ------ | ------ | ------ |
| `actor` | null \| \{ \[x: string]: unknown; sub: string; \} | The JWT actor for the session. Holds identifier for the user that is impersonating the current user. Read more about [impersonation](/docs/guides/users/impersonation). |
| `getToken()` | (options?: GetTokenOptions) => Promise\ | A function that retrieves the current user's session token or a custom JWT template. Returns a promise that resolves to the token. See the reference doc. |
| `has()` | (isAuthorizedParams: CheckAuthorizationParamsWithCustomPermissions) => boolean | A function that checks if the user has specific permissions or roles. See the reference doc. |
| `isLoaded` | `true` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `true` | A boolean that indicates whether a user is currently signed in. |
| `orgId` | `string` | The ID of the user's active organization. |
| `orgRole` | `string` | The current user's role in their active organization. |
| `orgSlug` | null \| string | The URL-friendly identifier of the user's active organization. |
| `sessionClaims` | `JwtPayload` | The current user's [session claims](/docs/guides/sessions/session-tokens). |
| `sessionId` | `string` | The ID for the current session. |
| `signOut()` | \{ (options?: SignOutOptions): Promise\; (signOutCallback?: SignOutCallback, options?: SignOutOptions): Promise\; \} | A function that signs out the current user. Returns a promise that resolves when complete. See the reference doc. |
| `userId` | `string` | The ID of the current user. |
## Example
The following example demonstrates how to use the `useAuth()` hook to access the current auth state, like whether the user is signed in or not. It also includes a basic example for using the `getToken()` method to retrieve a session token for fetching data from an external resource.
```tsx {{ filename: 'app/routes/index.tsx' }}
import { useAuth } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: ExternalDataPage,
})
function ExternalDataPage() {
const { userId, sessionId, getToken, isLoaded, isSignedIn } = useAuth()
const fetchExternalData = async () => {
const token = await getToken()
// Fetch data from an external API
const response = await fetch('https://api.example.com/data', {
headers: {
Authorization: `Bearer ${token}`,
},
})
return response.json()
}
// Handle loading state
if (!isLoaded) return
Loading...
// Protect the page from unauthenticated users
if (!isSignedIn) return
Sign in to view this page
return (
Hello, {userId}! Your current active session is {sessionId}.
Fetch Data
)
}
```
---
title: useClerk()
description: Access and manage the Clerk object in your React application with
Clerk's useClerk() hook.
sdk: chrome-extension, expo, nextjs, react, react-router, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-clerk
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: chrome-extension,expo,nextjs,react,react-router,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,remix,go,astro,nuxt,vue,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/hooks/use-clerk.mdx
---
> \[!WARNING]
> This hook should only be used for advanced use cases, such as building a completely custom OAuth flow or as an escape hatch to access to the `Clerk` object.
The `useClerk()` hook provides access to the Clerk object, allowing you to build alternatives to any Clerk Component.
## Returns
Clerk — The `useClerk()` hook returns the `Clerk` object, which includes all the methods and properties listed in the Clerk reference.
## Example
The following example uses the `useClerk()` hook to access the `clerk` object. The `clerk` object is used to call the openSignIn() method to open the sign-in modal.
```tsx {{ filename: 'app/routes/index.tsx' }}
import { useClerk } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
export default function Home() {
const clerk = useClerk()
return clerk.openSignIn({})}>Sign in
}
```
---
title: Hooks Reference
description: A list of Clerk's comprehensive suite of hooks for managing
authentication, sessions, sign-in and sign-up flows, Organizations, and
reverification.
sdk: astro, chrome-extension, expo, nextjs, react, react-router, remix,
tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/overview
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,react,react-router,remix,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,nuxt,vue,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/hooks/overview.mdx
---
Clerk offers a comprehensive suite of hooks that expose low-level access to authentication, session management, and multi-tenancy. With Clerk hooks, you can access and manage user data, handle sign-in and sign-up flows, control session management, and implement advanced flows like session reverification for sensitive actions. By using these hooks, you can extend or replace Clerk's built-in components and customize how authentication behaves in your application.
## Hooks
* useUser()
* useClerk()
* useAuth()
* useSignIn()
* useSignUp()
* useSession()
* useSessionList()
* useOrganization()
* useOrganizationList()
* useReverification()
* useCheckout()
* usePaymentElement()
* usePaymentMethods()
* usePlans()
* useSubscription()
* useStatements()
* usePaymentAttempts()
* [Join our Discord](https://clerk.com/discord "Join Discord")
* Join our official Discord server to chat with us directly and become a part of the Clerk community.
* {}
***
* [Need help?](/support "Get help")
* Contact us through Discord, Twitter, or email to receive answers to your questions and learn more about Clerk.
* {}
---
title: useReverification()
description: Clerk's useReverification() hook enhances a fetcher function to
handle a session's reverification flow.
sdk: chrome-extension, expo, nextjs, react, react-router, remix,
tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-reverification
lastUpdated: 2025-11-21T22:25:46.000Z
availableSdks: chrome-extension,expo,nextjs,react,react-router,remix,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/hooks/use-reverification.mdx
---
> \[!WARNING]
>
> Depending on the SDK you're using, this feature requires `@clerk/nextjs@6.12.7` or later, `@clerk/clerk-react@5.25.1` or later, `@clerk/clerk-js@5.57.1` or later and `@clerk/clerk-sdk-ruby@3.3.0` or later.
Reverification allows you to prompt a user to verify their credentials before performing sensitive actions, even if they're already authenticated. For example, in a banking application, transferring money is considered a "sensitive action." Reverification can be used to confirm the user's identity.
The `useReverification()` hook is used to handle a session's reverification flow. If a request requires reverification, a modal will display, prompting the user to verify their credentials. Upon successful verification, the original request will automatically retry. If you'd like to build a custom UI, you can use the onNeedsReverification option.
When using reverification, a user's credentials are valid for 10 minutes. Once stale, a user will need to reverify their credentials. This time duration can be customized by using the `has()` helper on the server-side. See the [guide on reverification](/docs/guides/secure/reverification) for more information.
## Parameters
| Parameter | Type | Description |
| ---------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `fetcher` | `Fetcher extends (...args: any[]) => Promise` | A function that returns a promise. |
| `options?` | `Options` | Optional configuration object extending UseReverificationOptions. |
### `UseReverificationOptions`
The optional options object.
| Property | Type | Description |
| ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `onNeedsReverification?` | (properties: NeedsReverificationParameters) => void | Handler for the reverification process. Opts out of using the default UI. Use this to build a custom UI. |
### `NeedsReverificationParameters`
| Property | Type | Description |
| -------------------------------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| `cancel` | () => void | Marks the reverification process as cancelled and rejects the original request. |
| `complete` | () => void | Marks the reverification process as complete and retries the original request. |
| `level` | undefined \| "first\_factor" \| "second\_factor" \| "multi\_factor" | The verification level required for the reverification process. |
## Examples
The `useReverification()` hook displays a prebuilt UI when the user needs to reverify their credentials. You can also build a custom UI to handle the reverification process yourself. Use the following tabs to see examples of either option.
### Handle reverification for an action
The following example demonstrates how to use the `useReverification()` hook to require a user to reverify their credentials before being able to update their primary email address. It also demonstrates how to handle the cancellation of the reverification process.
```tsx {{ filename: 'components/UpdateUserEmail.tsx', collapsible: true }}
import { useReverification, useUser } from '@clerk/tanstack-react-start'
import { isClerkRuntimeError, isReverificationCancelledError } from '@clerk/shared'
export function UpdateUserEmail() {
// Use `useUser()` to get the current user's `User` object
// `User` includes the `update()` method to update the user's primary email address
const { user } = useUser()
// Use `useReverification()` to enhance the `update()` method
// to handle the reverification process
const changePrimaryEmail = useReverification((emailAddressId: string) =>
user?.update({ primaryEmailAddressId: emailAddressId }),
)
const handleClick = async (emailAddressId: string) => {
try {
await changePrimaryEmail(emailAddressId)
} catch (e) {
// Handle if user cancels the reverification process
if (isClerkRuntimeError(e) && isReverificationCancelledError(e)) {
console.error('User cancelled reverification', e.code)
}
// Handle other errors
// See https://clerk.com/docs/custom-flows/error-handling
// for more info on error handling
console.error(JSON.stringify(e, null, 2))
}
}
return (
Your primary email address is {user?.primaryEmailAddress?.emailAddress}
)
}
```
### Handle reverification for a fetcher function
The following example demonstrates how to use the `useReverification()` hook to enhance a fetcher function that fetches data from a route that requires reverification. For examples on how to set up a route that requires reverification, see the [guide on reverification](/docs/guides/secure/reverification).
```tsx {{ filename: 'src/components/AccountBalance.tsx' }}
import { useReverification } from '@clerk/tanstack-react-start'
import { isClerkRuntimeError, isReverificationCancelledError } from '@clerk/shared'
import { useState } from 'react'
export function AccountBalance() {
const [balance, setBalance] = useState(null)
const accountBalance = useReverification(async () => {
const response = await fetch('/api/balance')
return await response.json()
})
const handleClick = async () => {
try {
const accountBalanceResponse = await accountBalance()
setBalance(accountBalanceResponse.amount)
} catch (e) {
// Handle if user cancels the reverification process
if (isClerkRuntimeError(e) && isReverificationCancelledError(e)) {
console.error('User cancelled reverification', e.code)
}
// Handle other errors
// See https://clerk.com/docs/custom-flows/error-handling
// for more info on error handling
console.error(JSON.stringify(e, null, 2))
}
}
return (
Your account balance is {balance ? `$${balance}` : '$******'} handleClick()}>See account balance
)
}
```
The following example demonstrates how to build a custom UI when using the `useReverification()` hook. In the example, the `useReverification()` hook is used to require a user to reverify their credentials before being able to update their primary email address. It requires two components: the `` component displays the list of email addresses to choose from and it renders the second component, ``, which handles the reverification process.
The example handles first factor verification using an email code, so you will need to have the [**Email verification code**](/docs/guides/configure/auth-strategies/sign-up-sign-in-options#email) setting enabled for your application. But you can adapt this example to handle any type of verification level or strategy.
The `` component uses `useReverification()` to enhance the `update()` method, requiring the user to reverify their credentials before being able to update their primary email address.
The `useReverification()` hook provides the `onNeedsReverification` option, which is a handler for building a custom UI. It provides four properties: `level`, `complete`, `cancel`, and `inProgress`. The example tracks these using the `verificationState` state variable.
* The `level` property determines the verification level required for the reverification process. This example only handles first factor verification, which is done in the `` component.
* The `complete` and `cancel` properties are the steps of the reverification process, which is also done in the `` component.
* The `inProgress` property is used to track the state of the reverification process. When the user selects the "Make primary" button, it triggers the reverification process and sets the `inProgress` property is `true`, which displays the `` component.
```tsx {{ filename: 'components/UpdateUserEmail.tsx', collapsible: true }}
import { useReverification, useUser } from '@clerk/tanstack-react-start'
import { isClerkRuntimeError, isReverificationCancelledError } from '@clerk/shared'
import { useState } from 'react'
import { SessionVerificationLevel } from '@clerk/types'
import { VerificationComponent } from './VerificationComponent'
export function UpdateUserEmail() {
// Use `useUser()` to get the current user's `User` object
// `User` includes the `update()` method to update the user's primary email address
const { user } = useUser()
// TODO: Update to use exported type once available
const [verificationState, setVerificationState] = useState<
| {
complete: () => void
cancel: () => void
level: SessionVerificationLevel | undefined
inProgress: boolean
}
| undefined
>(undefined)
// Use `useReverification()` to enhance the `update()` method
// to handle the reverification process
const changePrimaryEmail = useReverification(
(emailAddressId: string) => user?.update({ primaryEmailAddressId: emailAddressId }),
{
onNeedsReverification: ({ complete, cancel, level }) => {
setVerificationState({
complete,
cancel,
level,
inProgress: true,
})
},
},
)
const handleClick = async (emailAddressId: string) => {
try {
await changePrimaryEmail(emailAddressId)
} catch (e) {
// Handle if user cancels the reverification process
if (isClerkRuntimeError(e) && isReverificationCancelledError(e)) {
console.error('User cancelled reverification', e.code)
}
// Handle other errors
// See https://clerk.com/docs/custom-flows/error-handling
// for more info on error handling
console.error(JSON.stringify(e, null, 2))
}
}
return (
Your primary email address is {user?.primaryEmailAddress?.emailAddress}
)
}
```
The `` component handles the reverification process. It uses the `level` property to determine the verification level, which is set to `first_factor`. First, it finds the determined starting first factor from the supported first factors. Then, it prepares the first factor verification using the `strategy` (`email_code` in this case) and `emailAddressId` properties. Finally, it attempts to verify the session with email code provided by the user. If the verification is successful, the `onComplete()` handler is called to complete the reverification process.
```tsx {{ filename: 'components/VerificationComponent.tsx', collapsible: true }}
import { useEffect, useRef, useState } from 'react'
import { useSession } from '@clerk/tanstack-react-start'
import {
EmailCodeFactor,
SessionVerificationLevel,
SessionVerificationResource,
} from '@clerk/types'
export function VerificationComponent({
level = 'first_factor',
onComplete,
onCancel,
}: {
level: SessionVerificationLevel | undefined
onComplete: () => void
onCancel: () => void
}) {
const { session } = useSession()
const [code, setCode] = useState('')
const reverificationRef = useRef(undefined)
const [determinedStartingFirstFactor, setDeterminedStartingFirstFactor] = useState<
EmailCodeFactor | undefined
>()
useEffect(() => {
if (reverificationRef.current) {
return
}
session?.startVerification({ level }).then(async (response) => {
reverificationRef.current = response
await prepareEmailVerification(response)
})
}, [])
const prepareEmailVerification = async (verificationResource: SessionVerificationResource) => {
// To simplify the example we will only handle the first factor verification
if (verificationResource.status === 'needs_first_factor') {
// Determine the starting first factor from the supported first factors
const determinedStartingFirstFactor = verificationResource.supportedFirstFactors?.filter(
(factor) => factor.strategy === 'email_code',
)[0]
if (determinedStartingFirstFactor) {
setDeterminedStartingFirstFactor(determinedStartingFirstFactor)
// Prepare the first factor verification with the determined starting first factor
await session?.prepareFirstFactorVerification({
strategy: determinedStartingFirstFactor.strategy,
emailAddressId: determinedStartingFirstFactor?.emailAddressId,
})
}
}
}
const handleVerificationAttempt = async () => {
try {
// Attempt to verify the session with the provided code
await session?.attemptFirstFactorVerification({
strategy: 'email_code',
code,
})
onComplete()
} catch (e) {
// Any error from the attempt to verify the session can be handled here
console.error('Error verifying session', e)
}
}
if (!determinedStartingFirstFactor) {
return null
}
return (
Enter verification code sent to {determinedStartingFirstFactor.safeIdentifier || ''}
)
}
```
## Related guides
See the custom flowA **custom flow** refers to a user interface built entirely from scratch using the Clerk API. Learn more about [custom flows](/docs/guides/development/custom-flows/overview). guides for examples of how to use the `useReverification()` hook, such as the [Add a phone number to a user's account](/docs/guides/development/custom-flows/account-updates/add-phone) guide.
---
title: useOrganization()
description: Access and manage the currently active Organization in your React
application with Clerk's useOrganization() hook.
search:
rank: 1
sdk: chrome-extension, expo, nextjs, react, react-router, remix,
tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-organization
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: chrome-extension,expo,nextjs,react,react-router,remix,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/hooks/use-organization.mdx
---
The `useOrganization()` hook retrieves attributes of the currently Active OrganizationA user can be a member of multiple Organizations, but only one can be active at a time. The **Active Organization** determines which Organization-specific data the user can access and which Role and related Permissions they have within the Organization..
## Parameters
`useOrganization()` accepts a single object with the following optional properties:
| Property | Type | Description |
| ----------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `domains?` | true \| \{ initialPage?: number; pageSize?: number; \} & \{ enrollmentMode?: "manual\_invitation" \| "automatic\_invitation" \| "automatic\_suggestion"; \} & \{ infinite?: boolean; keepPreviousData?: boolean; \} | If set to `true`, all default properties will be used. Otherwise, accepts an object with the following optional properties:
`enrollmentMode`: A string that filters the domains by the provided [enrollment mode](/docs/guides/organizations/verified-domains#enrollment-mode).
Any of the properties described in Shared properties.
|
| `invitations?` | true \| \{ initialPage?: number; pageSize?: number; \} & \{ status?: ("expired" \| "pending" \| "accepted" \| "revoked")\[]; \} & \{ infinite?: boolean; keepPreviousData?: boolean; \} | If set to `true`, all default properties will be used. Otherwise, accepts an object with the following optional properties:
`status`: A string that filters the invitations by the provided status.
Any of the properties described in Shared properties.
|
| `membershipRequests?` | true \| \{ initialPage?: number; pageSize?: number; \} & \{ status?: "expired" \| "pending" \| "accepted" \| "revoked"; \} & \{ infinite?: boolean; keepPreviousData?: boolean; \} | If set to `true`, all default properties will be used. Otherwise, accepts an object with the following optional properties:
`status`: A string that filters the membership requests by the provided status.
Any of the properties described in Shared properties.
|
| `memberships?` | true \| \{ initialPage?: number; pageSize?: number; \} & \{ query?: string; role?: string\[]; \} & \{ infinite?: boolean; keepPreviousData?: boolean; \} | If set to `true`, all default properties will be used. Otherwise, accepts an object with the following optional properties:
`role`: An array of OrganizationCustomRoleKey.
`query`: A string that filters the memberships by the provided string.
Any of the properties described in Shared properties.
|
> \[!WARNING]
> By default, the `memberships`, `invitations`, `membershipRequests`, and `domains` attributes aren't populated. To fetch and paginate the data, you must pass `true` or an object with the desired properties.
### Shared properties
Optional properties that are shared across the `invitations`, `membershipRequests`, `memberships`, and `domains` properties.
| Property | Type | Description |
| --------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `initialPage?` | `number` | A number that specifies which page to fetch. For example, if `initialPage` is set to 10, it will skip the first 9 pages and fetch the 10th page. Defaults to `1`. |
| `pageSize?` | `number` | A number that specifies the maximum number of results to return per page. Defaults to `10`. |
| Name | Type | Description |
| ------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `infinite?` | `boolean` | If `true`, newly fetched data will be appended to the existing list rather than replacing it. Useful for implementing infinite scroll functionality. Defaults to `false`. |
| `keepPreviousData?` | `boolean` | If `true`, the previous data will be kept in the cache until new data is fetched. Defaults to `false`. |
> \[!NOTE]
> These attributes are updating automatically and will re-render their respective components whenever you set a different Organization using the setActive(\{ organization }) method or update any of the memberships or invitations. No need for you to manage updating anything manually.
## Returns
| Property | Type | Description |
| ---------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `domains` | null \| PaginatedResourcesWithDefault\<OrganizationDomainResource\> \| PaginatedResources\<OrganizationDomainResource, T\["membershipRequests"] *extends* \{ infinite: true; \} ? true : false\> | Includes a paginated list of the organization's domains. |
| `invitations` | null \| PaginatedResourcesWithDefault\<OrganizationInvitationResource\> \| PaginatedResources\<OrganizationInvitationResource, T\["invitations"] *extends* \{ infinite: true; \} ? true : false\> | Includes a paginated list of the organization's invitations. |
| `isLoaded` | `boolean` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `membership` | undefined \| null \| OrganizationMembershipResource | The current organization membership. |
| `membershipRequests` | null \| PaginatedResourcesWithDefault\<OrganizationMembershipRequestResource\> \| PaginatedResources\<OrganizationMembershipRequestResource, T\["membershipRequests"] *extends* \{ infinite: true; \} ? true : false\> | Includes a paginated list of the organization's membership requests. |
| `memberships` | null \| PaginatedResourcesWithDefault\<OrganizationMembershipResource\> \| PaginatedResources\<OrganizationMembershipResource, T\["memberships"] *extends* \{ infinite: true; \} ? true : false\> | Includes a paginated list of the organization's memberships. |
| `organization` | undefined \| null \| OrganizationResource | The currently active organization. |
### `PaginatedResources`
| Property | Type | Description |
| ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `count` | `number` | The total count of data that exist remotely. |
| `data` | T\[] | An array that contains the fetched data. For example, for the `memberships` attribute, data will be an array of OrganizationMembership objects. |
| `error` | null \| ClerkAPIResponseError | Clerk's API response error object. |
| `fetchNext` | () => void | A function that triggers the next page to be loaded. This is the same as `fetchPage(page => Math.min(pageCount, page + 1))`. |
| `fetchPage` | `ValueOrSetter`\<`number`\> | A function that triggers a specific page to be loaded. |
| `fetchPrevious` | () => void | A function that triggers the previous page to be loaded. This is the same as `fetchPage(page => Math.max(0, page - 1))`. |
| `hasNextPage` | `boolean` | A boolean that indicates if there are available pages to be fetched. |
| `hasPreviousPage` | `boolean` | A boolean that indicates if there are available pages to be fetched. |
| `isError` | `boolean` | A boolean that indicates the request failed. |
| `isFetching` | `boolean` | A boolean that is `true` if there is an ongoing request or a revalidation. |
| `isLoading` | `boolean` | A boolean that is `true` if there is an ongoing request and there is no fetched data. |
| `page` | `number` | The current page. |
| `pageCount` | `number` | The total amount of pages. It is calculated based on `count`, `initialPage`, and `pageSize`. |
| `revalidate` | () => Promise\ | A function that triggers a revalidation of the current page. |
| `setData` | `Infinite` *extends* `true` ? `CacheSetter`\<(undefined \| ClerkPaginatedResponse\)\[]\> : `CacheSetter`\<undefined \| ClerkPaginatedResponse\\> | A function that allows you to set the data manually. |
To see the different Organization features integrated into one application, take a look at our [Organizations demo repository](https://github.com/clerk/organizations-demo).
## Examples
### Expand and paginate attributes
To keep network usage to a minimum, developers are required to opt-in by specifying which resource they need to fetch and paginate through. By default, the `memberships`, `invitations`, `membershipRequests`, and `domains` attributes are not populated. You must pass `true` or an object with the desired properties to fetch and paginate the data.
```jsx
// invitations.data will never be populated.
const { invitations } = useOrganization()
// Use default values to fetch invitations, such as initialPage = 1 and pageSize = 10
const { invitations } = useOrganization({
invitations: true,
})
// Pass your own values to fetch invitations
const { invitations } = useOrganization({
invitations: {
pageSize: 20,
initialPage: 2, // skips the first page
},
})
// Aggregate pages in order to render an infinite list
const { invitations } = useOrganization({
invitations: {
infinite: true,
},
})
```
### Infinite pagination
The following example demonstrates how to use the `infinite` property to fetch and append new data to the existing list. The `memberships` attribute will be populated with the first page of the Organization's memberships. When the "Load more" button is clicked, the `fetchNext` helper function will be called to append the next page of memberships to the list.
```tsx {{ filename: 'app/routes/members.tsx' }}
import { useOrganization } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/members')({
component: MemberListPage,
})
export default function MemberListPage() {
const { memberships } = useOrganization({
memberships: {
infinite: true, // Append new data to the existing list
keepPreviousData: true, // Persist the cached data until the new data has been fetched
},
})
// Handle loading state
if (!memberships) return
)
}
```
### Simple pagination
The following example demonstrates how to use the `fetchPrevious` and `fetchNext` helper functions to paginate through the data. The `memberships` attribute will be populated with the first page of the Organization's memberships. When the "Previous page" or "Next page" button is clicked, the `fetchPrevious` or `fetchNext` helper function will be called to fetch the previous or next page of memberships.
Notice the difference between this example's pagination and the infinite pagination example above.
```tsx {{ filename: 'app/routes/members-paginated.tsx' }}
import { useOrganization } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/members-paginated')({
component: MemberListPage,
})
export default function MemberListPage() {
const { memberships } = useOrganization({
memberships: {
keepPreviousData: true, // Persist the cached data until the new data has been fetched
},
})
// Handle loading state
if (!memberships) return
)
}
```
## Related guides
* [Update an Organization](/docs/guides/development/custom-flows/organizations/update-organizations)
* Use Clerk's API to build a custom flow for updating an Organization
***
* [Manage Roles in an Organization](/docs/guides/development/custom-flows/organizations/manage-roles)
* Use Clerk's API to build a custom flow for managing Roles in an Organization
***
* [Manage an Organization's membership requests](/docs/guides/development/custom-flows/organizations/manage-membership-requests)
* Use Clerk's API to build a custom flow for managing an Organization's membership requests
***
* [Manage a user's Organization invitations](/docs/guides/development/custom-flows/organizations/manage-user-org-invitations)
* Use Clerk's API to build a custom flow for managing user's Organization invitations
---
title: useSession()
description: Access and manage the current user's session in your React
application with Clerk's useSession() hook.
sdk: chrome-extension, expo, nextjs, react, react-router, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-session
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: chrome-extension,expo,nextjs,react,react-router,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,remix,go,astro,nuxt,vue,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/hooks/use-session.mdx
---
The `useSession()` hook provides access to the current user's Session object, as well as helpers for setting the active session.
## Returns
There are multiple variants of this type available which you can select by clicking on one of the tabs.
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `false` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `undefined` | A boolean that indicates whether a user is currently signed in. |
| `session` | `undefined` | The current session for the user. |
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `true` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `false` | A boolean that indicates whether a user is currently signed in. |
| `session` | `null` | The current session for the user. |
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `true` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `boolean` | A boolean that indicates whether a user is currently signed in. |
| `session` | SignedInSessionResource | The current session for the user. |
## Example
### Access the `Session` object
The following example uses the `useSession()` hook to access the `Session` object, which has the `lastActiveAt` property. The `lastActiveAt` property is a `Date` object used to show the time the session was last active.
```tsx {{ filename: 'app/routes/index.tsx' }}
import { useSession } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: HomePage,
})
function HomePage() {
const { isLoaded, session, isSignedIn } = useSession()
// Handle loading state
if (!isLoaded) return
Loading...
// Protect the page from unauthenticated users
if (!isSignedIn) return
Sign in to view this page
return (
This session has been active since {session.lastActiveAt.toLocaleString()}
)
}
```
---
title: useSignIn()
description: Access and manage the current user's sign-in state in your React
application with Clerk's useSignIn() hook.
sdk: chrome-extension, expo, nextjs, react, react-router, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-sign-in
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: chrome-extension,expo,nextjs,react,react-router,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,remix,go,astro,nuxt,vue,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/hooks/use-sign-in.mdx
---
The `useSignIn()` hook provides access to the SignIn object, which allows you to check the current state of a sign-in attempt and manage the sign-in flow. You can use this to create a [custom sign-in flow](/docs/guides/development/custom-flows/overview#sign-in-flow).
## Returns
There are multiple variants of this type available which you can select by clicking on one of the tabs.
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `false` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `setActive` | `undefined` | A function that sets the active session. See the reference doc. |
| `signIn` | `undefined` | An object that contains the current sign-in attempt status and methods to create a new sign-in attempt. |
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `true` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `setActive()` | (setActiveParams: SetActiveParams) => Promise\ | A function that sets the active session. See the reference doc. |
| `signIn` | SignInResource | An object that contains the current sign-in attempt status and methods to create a new sign-in attempt. |
## Examples
### Check the current state of a sign-in
The following example uses the `useSignIn()` hook to access the SignIn object, which contains the current sign-in attempt status and methods to create a new sign-in attempt. The `isLoaded` property is used to handle the loading state.
```tsx {{ filename: 'app/routes/index.tsx' }}
import { useSignIn } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: SignInPage,
})
export default function SignInPage() {
const { isLoaded, signIn } = useSignIn()
// Handle loading state
if (!isLoaded) return
Loading...
return
The current sign-in attempt status is {signIn?.status}.
}
```
### Create a custom sign-in flow with `useSignIn()`
The `useSignIn()` hook can also be used to build fully custom sign-in flows, if Clerk's prebuilt components don't meet your specific needs or if you require more control over the authentication flow. Different sign-in flows include email and password, email and phone codes, email links, and multifactor (MFA). To learn more about using the `useSignIn()` hook to create custom flows, see the [custom flow guides](/docs/guides/development/custom-flows/overview).
---
title: useUser()
description: Access and manage the current user's data in your React application
with Clerk's useUser() hook.
sdk: chrome-extension, expo, nextjs, react, react-router, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-user
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: chrome-extension,expo,nextjs,react,react-router,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,remix,go,astro,nuxt,vue,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/hooks/use-user.mdx
---
The `useUser()` hook provides access to the current user's User object, which contains all the data for a single user in your application and provides methods to manage their account. This hook also allows you to check if the user is signed in and if Clerk has loaded and initialized.
## Returns
There are multiple variants of this type available which you can select by clicking on one of the tabs.
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `false` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `undefined` | A boolean that returns `true` if the user is signed in. |
| `user` | `undefined` | The `User` object for the current user. |
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `true` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `false` | A boolean that returns `true` if the user is signed in. |
| `user` | `null` | The `User` object for the current user. |
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `true` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `true` | A boolean that returns `true` if the user is signed in. |
| `user` | UserResource | The `User` object for the current user. |
## Examples
### Get the current user
The following example uses the `useUser()` hook to access the User object, which contains the current user's data such as their full name. The `isLoaded` and `isSignedIn` properties are used to handle the loading state and to check if the user is signed in, respectively.
```tsx {{ filename: 'app/routes/index.tsx' }}
import { useUser } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
export default function Home() {
const { isSignedIn, user, isLoaded } = useUser()
// Handle loading state
if (!isLoaded) return
Loading...
// Protect the page from unauthenticated users
if (!isSignedIn) return
Sign in to view this page
return
Hello {user.firstName}!
}
```
### Update user data
The following example uses the `useUser()` hook to access the User object, which calls the update() method to update the current user's information.
```tsx {{ filename: 'app/routes/index.tsx' }}
import { useUser } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
export default function Home() {
const { isSignedIn, isLoaded, user } = useUser()
// Handle loading state
if (!isLoaded) return
Loading...
// Protect the page from unauthenticated users
if (!isSignedIn) return
>
)
}
```
### Reload user data
The following example uses the `useUser()` hook to access the User object, which calls the reload() method to get the latest user's information.
```tsx {{ filename: 'app/routes/index.tsx' }}
import { useUser } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
export default function Home() {
const { isSignedIn, isLoaded, user } = useUser()
// Handle loading state
if (!isLoaded) return
Loading...
// Protect the page from unauthenticated users
if (!isSignedIn) return
Sign in to view this page
const updateUser = async () => {
// Update data via an API endpoint
const updateMetadata = await fetch('/api/updateMetadata', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
role: 'admin',
}),
})
// Check if the update was successful
if ((await updateMetadata.json()).message !== 'success') {
throw new Error('Error updating')
}
// If the update was successful, reload the user data
await user.reload()
}
return (
<>
Update your metadata
user role: {user.publicMetadata.role}
>
)
}
```
---
title: useSignUp()
description: Access and manage the current user's sign-up state in your React
application with Clerk's useSignUp() hook.
sdk: chrome-extension, expo, nextjs, react, react-router, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-sign-up
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: chrome-extension,expo,nextjs,react,react-router,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,remix,go,astro,nuxt,vue,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/hooks/use-sign-up.mdx
---
The `useSignUp()` hook provides access to the SignUp object, which allows you to check the current state of a sign-up attempt and manage the sign-up flow. You can use this to create a [custom sign-up flow](/docs/guides/development/custom-flows/overview#sign-up-flow).
## Returns
There are multiple variants of this type available which you can select by clicking on one of the tabs.
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `false` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `setActive` | `undefined` | A function that sets the active session. See the reference doc. |
| `signUp` | `undefined` | An object that contains the current sign-up attempt status and methods to create a new sign-up attempt. |
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `true` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `setActive()` | (setActiveParams: SetActiveParams) => Promise\ | A function that sets the active session. See the reference doc. |
| `signUp` | SignUpResource | An object that contains the current sign-up attempt status and methods to create a new sign-up attempt. |
## Examples
### Check the current state of a sign-up
The following example uses the `useSignUp()` hook to access the SignUp object, which contains the current sign-up attempt status and methods to create a new sign-up attempt. The `isLoaded` property is used to handle the loading state.
```tsx {{ filename: 'app/routes/index.tsx' }}
import { useSignUp } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: SignUpPage,
})
export default function SignUpPage() {
const { isLoaded, signUp } = useSignUp()
// Handle loading state
if (!isLoaded) return Loading...
return
The current sign-up attempt status is {signUp?.status}.
}
```
### Create a custom sign-up flow with `useSignUp()`
The `useSignUp()` hook can also be used to build fully custom sign-up flows, if Clerk's prebuilt components don't meet your specific needs or if you require more control over the authentication flow. Different sign-up flows include email and password, email and phone codes, email links, and multifactor (MFA). To learn more about using the `useSignUp()` hook to create custom flows, see the [custom flow guides](/docs/guides/development/custom-flows/overview).
---
title: useSessionList()
description: Access and manage the current user's session list in your React
application with Clerk's useSessionList() hook.
sdk: chrome-extension, expo, nextjs, react, react-router, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-session-list
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: chrome-extension,expo,nextjs,react,react-router,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,remix,go,astro,nuxt,vue,ruby,js-backend
activeSdk: tanstack-react-start
sourceFile: /docs/reference/hooks/use-session-list.mdx
---
The `useSessionList()` hook returns an array of Session objects that have been registered on the client device.
## Returns
There are multiple variants of this type available which you can select by clicking on one of the tabs.
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `false` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `sessions` | `undefined` | A list of sessions that have been registered on the client device. |
| `setActive` | `undefined` | A function that sets the active session and/or organization. See the reference doc. |
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `true` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `sessions` | SessionResource\[] | A list of sessions that have been registered on the client device. |
| `setActive()` | (setActiveParams: SetActiveParams) => Promise\ | A function that sets the active session and/or organization. See the reference doc. |
## Example
### Get a list of sessions
The following example uses `useSessionList()` to get a list of sessions that have been registered on the client device. The `sessions` property is used to show the number of times the user has visited the page.
```tsx {{ filename: 'app/routes/index.tsx' }}
import { useSessionList } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
export default function Home() {
const { isLoaded, sessions } = useSessionList()
// Handle loading state
if (!isLoaded) return
Loading...
return (
Welcome back. You've been here {sessions.length} times before.
)
}
```
---
title: Remix Quickstart
description: Learn how to use Clerk to quickly and easily add secure
authentication and user management to your Remix application.
sdk: nextjs, react, js-frontend, chrome-extension, expo, android, ios,
expressjs, fastify, react-router, remix, tanstack-react-start, go, astro,
nuxt, vue, ruby, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/getting-started/quickstart
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,react,js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
notAvailableSdks: ""
activeSdk: remix
sourceFile: /docs/getting-started/quickstart.remix.mdx
---
> \[!WARNING]
> The Remix SDK is in maintenance mode and will only receive security updates. Please migrate to the React Router SDK for continued development and new features.
Learn how to use Clerk to quickly and easily add secure authentication and user management to your Remix app. This guide assumes that you are using Remix v2 or later.
> \[!NOTE]
> If you are using Remix SPA mode, follow the [Remix SPA mode guide](/docs/guides/development/spa-mode).
## Install `@clerk/remix`
The [Clerk Remix SDK](/docs/reference/remix/overview) gives you access to prebuilt components, hooks, and helpers to make user authentication easier.
Run the following command to install the SDK:
```npm
npm install @clerk/remix
```
## Set your Clerk API keys
Add the following keys to your `.env` file. These keys can always be retrieved from the [**API keys**](https://dashboard.clerk.com/~/api-keys) page in the Clerk Dashboard.
1. In the Clerk Dashboard, navigate to the [**API keys**](https://dashboard.clerk.com/~/api-keys) page.
2. In the **Quick Copy** section, copy your Clerk Publishable and Secret Keys.
3. Paste your keys into your `.env` file.
The final result should resemble the following:
```env {{ filename: '.env' }}
CLERK_PUBLISHABLE_KEY={{pub_key}}
CLERK_SECRET_KEY={{secret}}
```
## Configure `rootAuthLoader()`
The [`rootAuthLoader()`](/docs/reference/remix/root-auth-loader) function is a helper function that provides the authentication state to your Remix application. You must export `rootAuthLoader()` as the root `loader()` function.
Update your `root.tsx` file with the following code:
```tsx {{ filename: 'app/root.tsx', mark: [1, [4, 5], [15, 16]] }}
import type { MetaFunction, LoaderFunction } from '@remix-run/node'
import { Links, Meta, Outlet, Scripts, ScrollRestoration } from '@remix-run/react'
// Import `rootAuthLoader()`
import { rootAuthLoader } from '@clerk/remix/ssr.server'
export const meta: MetaFunction = () => [
{
charset: 'utf-8',
title: 'New Remix App',
viewport: 'width=device-width,initial-scale=1',
},
]
// Export `rootAuthLoader()` as the root route `loader`
export const loader: LoaderFunction = (args) => rootAuthLoader(args)
export function Layout({ children }: { children: React.ReactNode }) {
return (
{children}
)
}
export default function App() {
return
}
```
## Configure `ClerkApp`
Clerk provides a `ClerkApp` wrapper to provide the authentication state to your React tree. This helper works with Remix SSR out-of-the-box and follows the "higher-order component" paradigm.
Update your `root.tsx` file with the following code:
```tsx {{ filename: 'app/root.tsx', mark: [[6, 7], [39, 40]] }}
import type { MetaFunction, LoaderFunction } from '@remix-run/node'
import { Links, Meta, Outlet, Scripts, ScrollRestoration } from '@remix-run/react'
import { rootAuthLoader } from '@clerk/remix/ssr.server'
// Import ClerkApp
import { ClerkApp } from '@clerk/remix'
export const meta: MetaFunction = () => [
{
charset: 'utf-8',
title: 'New Remix App',
viewport: 'width=device-width,initial-scale=1',
},
]
export const loader: LoaderFunction = (args) => rootAuthLoader(args)
export function Layout({ children }: { children: React.ReactNode }) {
return (
{children}
)
}
function App() {
return
}
// Wrap your app with `ClerkApp`
export default ClerkApp(App)
```
## Protect your pages
### Client-side
To protect your pages on the client-side, Clerk's prebuilt control components control the visibility of content based on the user's authentication state.
The following example uses the following components:
* \: Children of this component can only be seen while **signed in**.
* \: Children of this component can only be seen while **signed out**.
* \: Shows the signed-in user's avatar. Selecting it opens a dropdown menu with account management options.
* \: An unstyled component that links to the sign-in page. In this example, since no props or [environment variables](/docs/guides/development/clerk-environment-variables) are set for the sign-in URL, this component links to the [Account Portal sign-in page](/docs/guides/customizing-clerk/account-portal#sign-in).
```tsx {{ filename: 'routes/_index.tsx' }}
import {
SignInButton,
SignOutButton,
SignUpButton,
SignedIn,
SignedOut,
UserButton,
} from '@clerk/remix'
export default function Index() {
return (
Index Route
You are signed in!
You are signed out
)
}
```
### Server-side
To protect your routes, use the getAuth() function in your loader. This function retrieves the authentication state from the request object, returning an Auth object that includes the `isAuthenticated`, allowing you to determine if the user is authenticated.
```tsx {{ filename: 'routes/_index.tsx' }}
import { UserButton } from '@clerk/remix'
import { getAuth } from '@clerk/remix/ssr.server'
import { LoaderFunction, redirect } from '@remix-run/node'
export const loader: LoaderFunction = async (args) => {
const { isAuthenticated } = await getAuth(args)
if (!isAuthenticated) {
return redirect('/sign-in')
}
return {}
}
export default function Index() {
return (
Index route
You are signed in!
)
}
```
## Create your first user
Run your project with the following command:
```npm
npm run dev
```
Visit your app's homepage at [`http://localhost:5173`](http://localhost:5173). Sign up to create your first user.
## Next steps
* [Create a custom sign-in-or-up page](/docs/remix/guides/development/custom-sign-in-or-up-page)
* Learn how add custom sign-in-or-up page with Clerk components.
***
* [Protect content and read user data](/docs/remix/guides/users/reading)
* Learn how to use Clerk's hooks and helpers to access the session and user data in your Remix app.
***
* [Customization & localization](/docs/guides/customizing-clerk/appearance-prop/overview)
* Learn how to customize and localize the Clerk components.
***
* [Clerk components](/docs/reference/components/overview)
* Learn more about the prebuilt components.
---
title: Clerk Billing for B2B SaaS
description: Clerk Billing is a feature that allows you to create and manage
Plans and Features for your application.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/billing/for-b2b
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: remix
sourceFile: /docs/guides/billing/for-b2b.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing for B2B SaaS allows you to create Plans and manage Subscriptions **for companies or organizations** in your application. If you'd like to charge individual users, see Billing for B2C SaaS. You can also combine both B2C and B2B Billing in the same application.
## Enable Billing
To enable Billing for your application, navigate to the [**Billing Settings**](https://dashboard.clerk.com/~/billing/settings) page in the Clerk Dashboard. This page will guide you through enabling Billing for your application.
Clerk Billing costs the same as using Stripe Billing directly, just 0.7% per transaction, plus transaction fees which are paid directly to Stripe. Clerk Billing is **not** the same as Stripe Billing. Plans and pricing are managed directly through the Clerk Dashboard and won't sync with your existing Stripe products or plans. Clerk uses Stripe **only** for payment processing, so you don't need to set up Stripe Billing.
### Payment gateway
Once you have enabled Billing, you will see the following **Payment gateway** options for collecting payments via Stripe:
* **Clerk development gateway**: A shared **test** Stripe account used for development instances. This allows developers to test and build Billing flows **in development** without needing to create and configure a Stripe account.
* **Stripe account**: Use your own Stripe account for production. **A Stripe account created for a development instance cannot be used for production**. You will need to create a separate Stripe account for your production environment.
## Create a Plan
Subscription Plans are what your customers subscribe to. There is no limit to the number of Plans you can create. If your Clerk instance has existing [Custom Permissions](/docs/guides/organizations/roles-and-permissions), the corresponding Features from those Permissions will automatically be added to the free Plan for Orgs. This ensures that Organization members get the same set of Custom Permissions when Billing is enabled, because all Organizations start on the free Plan.
To create a Plan, navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard. Here, you can create, edit, and delete Plans. To setup B2B Billing, select the **Plans for Organizations** tab and select **Add Plan**. When creating a Plan, you can also create [Features](/docs/guides/secure/features) for the Plan; see the next section for more information.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's an Organization Plan, it can appear in the `` component. When creating or editing a Plan, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Add Features to a Plan
[Features](/docs/guides/secure/features) make it easy to give entitlements to your Plans. You can add any number of Features to a Plan.
You can add a Feature to a Plan when you are creating a Plan. To add it after a Plan is created:
1. Navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard.
2. Select the Plan you'd like to add a Feature to.
3. In the **Features** section, select **Add Feature**.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's an Organization Plan, it can appear in the `` component. When adding a Feature to a Plan, it will also automatically appear in the corresponding Plan. When creating or editing a Feature, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Create a pricing page
You can create a pricing page by using the \ component. This component displays a table of Plans and Features that customers can subscribe to. **It's recommended to create a dedicated page**, as shown in the following example.
```tsx {{ filename: 'app/routes/pricing.tsx' }}
import { PricingTable } from '@clerk/remix'
export default function PricingPage() {
return (
)
}
```
## Control access with Features, Plans, and Permissions
You can use Clerk's Features, Plans, and Permissions to gate access to content using authorization checksAuthorization checks are checks you perform in your code to determine the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions or access certain content. Learn more about [authorization checks](/docs/guides/secure/authorization-checks).. There are a few ways to do this, but the recommended approach is to either use the has() method or the \ component.
The `has()` method is available for any JavaScript-based framework, while `` is a component, and therefore, is only available for React-based frameworks.
> \[!IMPORTANT]
> Permission-based authorization checks link with Feature-based authorization checks. This means that if you are checking a Custom Permission, it will only work if the Feature part of the Permission key (`org::`) **is a Feature included in the Organization's active Plan**. For example, say you want to check if an Organization member has the Custom Permission `org:teams:manage`, where `teams` is the Feature. Before performing the authorization check, you need to ensure that the user's Organization is subscribed to a Plan that has the `teams` Feature. If the user's Organization is not subscribed to a Plan that has the `teams` Feature, the authorization check will always return `false`, *even if the user has the Custom Permission*.
### Example: Using `has()`
Use the `has()` method to test if the Organization has access to a **Plan**:
```jsx
const hasPremiumAccess = has({ plan: 'gold' })
```
Or a **Feature**:
```jsx
const hasPremiumAccess = has({ feature: 'widgets' })
```
The has() method is a server-side helper that checks if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan) and returns a boolean value. `has()` is available on the auth object, which you will access differently depending on the framework you are using.
> \[!TIP]
> Why aren't Custom Permissions appearing in the session token (JWT) or in API responses (including the result of the `has()` check)?
>
> ***
>
> Custom Permissions will only appear in the session token (JWT) and in API responses (including the result of the `has()` check) if the Feature part of the Permission key (`org::`) **is a Feature included in the Organization's active Plan**. If the Feature is not part of the Plan, the `has()` check for Permissions using that Feature will return `false`, and those Permissions will not be represented in the session token.
>
> For example, say you want to check if an Organization member has the Custom Permission `org:teams:manage`, where `teams` is the Feature. The user's Organization must be subscribed to a Plan that has the `teams` Feature for authorization checks to work. If the user's Organization is not subscribed to a Plan that has the `teams` Feature, the authorization check will always return `false`, *even if the user has the Custom Permission*.
The following example demonstrates how to use `has()` to check if an Organization has a Plan.
```tsx {{ filename: 'app/routes/bronze-content.tsx' }}
import { getAuth } from '@clerk/remix/ssr.server'
import { useLoaderData } from '@remix-run/react'
import type { LoaderFunctionArgs } from '@remix-run/node'
export const loader = async (args: LoaderFunctionArgs) => {
const { has } = await getAuth(args)
return { hasBronzePlan: has({ plan: 'bronze' }) }
}
export default function BronzeContentPage() {
const { hasBronzePlan } = useLoaderData()
if (!hasBronzePlan) return
Only subscribers to the Bronze plan can access this content.
return
For Bronze subscribers only
}
```
The following example demonstrates how to use `has()` to check if an Organization has a Feature.
```tsx {{ filename: 'app/routes/premium-content.tsx' }}
import { getAuth } from '@clerk/remix/ssr.server'
import { useLoaderData } from '@remix-run/react'
import type { LoaderFunctionArgs } from '@remix-run/node'
export const loader = async (args: LoaderFunctionArgs) => {
const { has } = await getAuth(args)
return { hasPremiumAccess: has({ feature: 'premium_access' }) }
}
export default function PremiumContentPage() {
const { hasPremiumAccess } = useLoaderData()
if (!hasPremiumAccess)
return
Only subscribers with the Premium Access feature can access this content.
return
Our Exclusive Content
}
```
The following example demonstrates how to use `has()` to check if an Organization has a Permission.
```tsx {{ filename: 'app/routes/manage-premium-content.tsx' }}
import { getAuth } from '@clerk/remix/ssr.server'
import { useLoaderData } from '@remix-run/react'
import type { LoaderFunctionArgs } from '@remix-run/node'
export const loader = async (args: LoaderFunctionArgs) => {
const { has } = await getAuth(args)
return { hasPremiumAccessManage: has({ permission: 'org:premium_access:manage' }) }
}
export default function ManagePremiumContentPage() {
const { hasPremiumAccessManage } = useLoaderData()
if (!hasPremiumAccessManage)
return (
Only subscribers with the Premium Access Manage permission can access this content.
)
return
Our Exclusive Content
}
```
### Example: Using ``
The \ component protects content or even entire routes by checking if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan). You can pass a `fallback` prop to `` that will be rendered if the Organization does not have the access control.
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Plan.
```tsx {{ filename: 'app/routes/protected-content.tsx' }}
import { Protect } from '@clerk/remix'
export default function ProtectedContentPage() {
return (
Only subscribers to the Bronze plan can access this content.}
>
Exclusive Bronze Content
This content is only visible to Bronze subscribers.
)
}
```
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Feature.
```tsx {{ filename: 'app/routes/protected-premium-content.tsx' }}
import { Protect } from '@clerk/remix'
export default function ProtectedPremiumContentPage() {
return (
Only subscribers with the Premium Access feature can access this content.}
>
Exclusive Premium Content
This content is only visible to users with Premium Access feature.
)
}
```
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Permission.
```tsx {{ filename: 'app/routes/protected-manage-content.tsx' }}
import { Protect } from '@clerk/remix'
export default function ProtectedManageContentPage() {
return (
Only subscribers with the Premium Access Manage permission can access this content.
}
>
Exclusive Management Content
This content is only visible to users with Premium Access Manage permission.
)
}
```
---
title: Clerk Billing for B2C SaaS
description: Clerk Billing is a feature that allows you to create and manage
Plans and Features for your application.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/billing/for-b2c
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: remix
sourceFile: /docs/guides/billing/for-b2c.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing for B2C SaaS allows you to create Plans and manage Subscriptions **for individual users** in your application. If you'd like to charge companies or organizations, see Billing for B2B SaaS. You can also combine both B2C and B2B Billing in the same application.
## Enable Billing
To enable Billing for your application, navigate to the [**Billing Settings**](https://dashboard.clerk.com/~/billing/settings) page in the Clerk Dashboard. This page will guide you through enabling Billing for your application.
Clerk Billing costs the same as using Stripe Billing directly, just 0.7% per transaction, plus transaction fees which are paid directly to Stripe. Clerk Billing is **not** the same as Stripe Billing. Plans and pricing are managed directly through the Clerk Dashboard and won't sync with your existing Stripe products or plans. Clerk uses Stripe **only** for payment processing, so you don't need to set up Stripe Billing.
### Payment gateway
Once you have enabled Billing, you will see the following **Payment gateway** options for collecting payments via Stripe:
* **Clerk development gateway**: A shared **test** Stripe account used for development instances. This allows developers to test and build Billing flows **in development** without needing to create and configure a Stripe account.
* **Stripe account**: Use your own Stripe account for production. **A Stripe account created for a development instance cannot be used for production**. You will need to create a separate Stripe account for your production environment.
## Create a Plan
Subscription Plans are what your users subscribe to. There is no limit to the number of Plans you can create.
To create a Plan, navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard. Here, you can create, edit, and delete Plans. To setup B2C Billing, select the **Plans for Users** tab and select **Add Plan**. When creating a Plan, you can also create Features for the Plan; see the next section for more information.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's a user Plan, it can appear in the `` component. When creating or editing a Plan, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Add Features to a Plan
[Features](/docs/guides/secure/features) make it easy to give entitlements to your Plans. You can add any number of Features to a Plan.
You can add a Feature to a Plan when you are creating a Plan. To add it after a Plan is created:
1. Navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard.
2. Select the Plan you'd like to add a Feature to.
3. In the **Features** section, select **Add Feature**.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's a user Plan, it can appear in the `` component. When adding a Feature to a Plan, it will also automatically appear in the corresponding Plan. When creating or editing a Feature, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Create a pricing page
You can create a pricing page by using the \ component. This component displays a table of Plans and Features that users can subscribe to. **It's recommended to create a dedicated page**, as shown in the following example.
```tsx {{ filename: 'app/routes/pricing.tsx' }}
import { PricingTable } from '@clerk/remix'
export default function PricingPage() {
return (
)
}
```
## Control access with Features and Plans
You can use Clerk's Features and Plans to gate access to the content. There are a few ways to do this, but the recommended approach is to either use the has() method or the \ component.
The `has()` method is available for any JavaScript framework, while `` is only available for React-based frameworks.
### Example: Using `has()`
Use the `has()` method to test if the user has access to a **Plan**:
```jsx
const hasPremiumAccess = has({ plan: 'gold' })
```
Or a **Feature**:
```jsx
const hasPremiumAccess = has({ feature: 'widgets' })
```
The has() method is a server-side helper that checks if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan) and returns a boolean value. `has()` is available on the auth object, which you will access differently depending on the framework you are using.
The following example demonstrates how to use `has()` to check if a user has a Plan.
```tsx {{ filename: 'app/routes/bronze-content.tsx' }}
import { getAuth } from '@clerk/remix/ssr.server'
import { useLoaderData } from '@remix-run/react'
import type { LoaderFunctionArgs } from '@remix-run/node'
export const loader = async (args: LoaderFunctionArgs) => {
const { has } = await getAuth(args)
return { hasBronzePlan: has({ plan: 'bronze' }) }
}
export default function BronzeContentPage() {
const { hasBronzePlan } = useLoaderData()
if (!hasBronzePlan) return
Only subscribers to the Bronze plan can access this content.
return
For Bronze subscribers only
}
```
The following example demonstrates how to use `has()` to check if a user has a Feature.
```tsx {{ filename: 'app/routes/premium-content.tsx' }}
import { getAuth } from '@clerk/remix/ssr.server'
import { useLoaderData } from '@remix-run/react'
import type { LoaderFunctionArgs } from '@remix-run/node'
export const loader = async (args: LoaderFunctionArgs) => {
const { has } = await getAuth(args)
return { hasPremiumAccess: has({ feature: 'premium_access' }) }
}
export default function PremiumContentPage() {
const { hasPremiumAccess } = useLoaderData()
if (!hasPremiumAccess)
return
Only subscribers with the Premium Access feature can access this content.
return
Our Exclusive Content
}
```
### Example: Using ``
The \ component protects content or even entire routes by checking if the user has been granted a specific type of access control (Role, Permission, Feature, or Plan). You can pass a `fallback` prop to `` that will be rendered if the user does not have the access control.
The following example demonstrates how to use `` to protect a page by checking if the user has a Plan.
```tsx {{ filename: 'app/routes/protected-content.tsx' }}
import { Protect } from '@clerk/remix'
export default function ProtectedContentPage() {
return (
Only subscribers to the Bronze plan can access this content.}
>
Exclusive Bronze Content
This content is only visible to Bronze subscribers.
)
}
```
The following example demonstrates how to use `` to protect a page by checking if the user has a Feature.
```tsx {{ filename: 'app/routes/protected-premium-content.tsx' }}
import { Protect } from '@clerk/remix'
export default function ProtectedPremiumContentPage() {
return (
Only subscribers with the Premium Access feature can access this content.}
>
Exclusive Premium Content
This content is only visible to users with Premium Access feature.
)
}
```
---
title: Build your own sign-in-or-up page for your Remix app with Clerk
description: Learn how to add a custom sign-in-or-up page to your Remix app with
Clerk's prebuilt components.
sdk: nextjs, react-router, remix, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/guides/development/custom-sign-in-or-up-page
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,react-router,remix,tanstack-react-start
notAvailableSdks: react,js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: remix
sourceFile: /docs/guides/development/custom-sign-in-or-up-page.remix.mdx
---
> \[!WARNING]
> The Remix SDK is in maintenance mode and will only receive security updates. Please migrate to the React Router SDK for continued development and new features.
This guide shows you how to use the \ component to build a custom page **that allows users to sign in or sign up within a single flow**.
To set up separate sign-in and sign-up pages, follow this guide, and then follow the [custom sign-up page guide](/docs/remix/guides/development/custom-sign-up-page).
> \[!NOTE]
> Just getting started with Clerk and Remix? See the [quickstart tutorial](/docs/remix/getting-started/quickstart)!
## Build a sign-in-or-up page
The following example demonstrates how to render the \ component on a dedicated page using the [Remix optional route](https://reactrouter.com/en/main/route/route#optional-segments).
```tsx {{ filename: 'app/routes/sign-in.$.tsx' }}
import { SignIn } from '@clerk/remix'
export default function Page() {
return
}
```
## Configure your sign-in-or-up page
* Set the `CLERK_SIGN_IN_URL` environment variable to tell Clerk where the `` component is being hosted.
* Set `CLERK_SIGN_IN_FALLBACK_REDIRECT_URL` as a fallback URL incase users visit the `/sign-in` route directly.
* Set `CLERK_SIGN_UP_FALLBACK_REDIRECT_URL` as a fallback URL incase users select the 'Don't have an account? Sign up' link at the bottom of the component.
Learn more about these environment variables and how to customize Clerk's redirect behavior in the [dedicated guide](/docs/guides/development/customize-redirect-urls).
```env {{ filename: '.env' }}
CLERK_SIGN_IN_URL=/sign-in
CLERK_SIGN_IN_FALLBACK_REDIRECT_URL=/
CLERK_SIGN_UP_FALLBACK_REDIRECT_URL=/
```
* Set the `signInUrl` property to your `ClerkApp` options to tell Clerk where the `` component is being hosted.
* Set the `signInFallbackRedirectUrl` property to a fallback URL incase users visit the `/sign-in` route directly.
* Set the `signUpFallbackRedirectUrl` property to a fallback URL incase users select the 'Don't have an account? Sign up' link at the bottom of the component.
Learn more about these environment variables and how to customize Clerk's redirect behavior in the [dedicated guide](/docs/guides/development/customize-redirect-urls).
```ts {{ filename: 'app/root.tsx', mark: [[3, 4]] }}
export default ClerkApp(App, {
publishableKey: PUBLISHABLE_KEY,
signInUrl: '/sign-in',
signInFallbackRedirectUrl: '/',
signUpFallbackRedirectUrl: '/',
})
```
## Visit your new page
Run your project with the following terminal command from the root directory of your project:
```npm
npm run dev
```
Visit your new custom page locally at [localhost:3000/sign-in](http://localhost:3000/sign-in).
## Next steps
* [Custom sign-up page](/docs/remix/guides/development/custom-sign-up-page)
* Learn how to add a custom sign-up page to your Remix app with Clerk's prebuilt components.
***
* [Protect content and read user data](/docs/remix/guides/users/reading)
* Learn how to use Clerk's hooks and helpers to access the session and user data in your Remix application.
---
title: Build your own sign-up page for your Remix app with Clerk
description: Learn how to add a custom sign-up page to your Remix app with
Clerk's prebuilt components.
sdk: nextjs, react-router, remix, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/guides/development/custom-sign-up-page
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,react-router,remix,tanstack-react-start
notAvailableSdks: react,js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: remix
sourceFile: /docs/guides/development/custom-sign-up-page.remix.mdx
---
> \[!WARNING]
> The Remix SDK is in maintenance mode and will only receive security updates. Please migrate to the React Router SDK for continued development and new features.
By default, the \ component handles signing in and signing up, but if you'd like to have a dedicated sign-up page, this guide shows you how to use the \ component to build a custom sign-up page.
To set up a single sign-in-or-up page, follow the [custom sign-in-or-up page guide](/docs/remix/guides/development/custom-sign-in-or-up-page).
> \[!NOTE]
> Just getting started with Clerk and Remix? See the [quickstart tutorial](/docs/remix/getting-started/quickstart)!
## Build a sign-up page
The following example demonstrates how to render the \ component on a dedicated sign-up page using the [Remix optional route](https://reactrouter.com/en/main/route/route#optional-segments).
```tsx {{ filename: 'app/routes/sign-up.$.tsx' }}
import { SignUp } from '@clerk/remix'
export default function Page() {
return
}
```
## Configure your sign-up page
* Set the `CLERK_SIGN_UP_URL` environment variable to tell Clerk where the `` component is being hosted.
* Set `CLERK_SIGN_UP_FALLBACK_REDIRECT_URL` as a fallback URL incase users visit the `/sign-up` route directly.
* Set `CLERK_SIGN_IN_FALLBACK_REDIRECT_URL` as a fallback URL incase users select the 'Already have an account? Sign in' link at the bottom of the component.
Learn more about these environment variables and how to customize Clerk's redirect behavior in the [dedicated guide](/docs/guides/development/customize-redirect-urls).
```env {{ filename: '.env' }}
CLERK_SIGN_UP_URL=/sign-up
CLERK_SIGN_UP_FALLBACK_REDIRECT_URL=/
CLERK_SIGN_IN_FALLBACK_REDIRECT_URL=/
```
* Set the `signUpUrl` property to your `ClerkApp` options to tell Clerk where the `` component is being hosted.
* Set the `signUpFallbackRedirectUrl` property to a fallback URL incase users visit the `/sign-up` route directly.
* Set the `signInFallbackRedirectUrl` property to a fallback URL incase users select the 'Already have an account? Sign in' link at the bottom of the component.
Learn more about these environment variables and how to customize Clerk's redirect behavior in the [dedicated guide](/docs/guides/development/customize-redirect-urls).
```ts {{ filename: 'app/root.tsx' }}
export default ClerkApp(App, {
publishableKey: PUBLISHABLE_KEY,
signUpUrl: '/sign-up',
signUpFallbackRedirectUrl: '/',
signInFallbackRedirectUrl: '/',
})
```
## Visit your new page
Run your project with the following command:
```npm
npm run dev
```
Visit your new custom page locally at [localhost:3000/sign-up](http://localhost:3000/sign-up).
## Next steps
* [Protect content and read user data](/docs/remix/guides/users/reading)
* Learn how to use Clerk's hooks and helpers to access the session and user data in your Remix application.
---
title: Clerk Billing webhooks
description: Clerk Billing webhooks allow you to track subscription lifecycles
and monitor payment attempts.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/development/webhooks/billing
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: remix
sourceFile: /docs/guides/development/webhooks/billing.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing supports webhook events that allow you to track information like subscription lifecycles and payments.
## Subscriptions
A subscription is a top-level container unique to each user or organization. Subscription events can help you track billing changes for each of your customers.
| Event Name | Description |
| - | - |
| `subscription.created` | The top-level subscription is created. This usually happens when a user or organization is created. For existing users and organizations, a subscription will be created when Billing is enabled for the application. |
| `subscription.updated` | The top-level subscription is updated. This event is triggered when any property of the subscription has changed, except for status changes. For example, when the subscription items for the payer change. |
| `subscription.active` | The top-level subscription transitions to active from a non-active status. This happens when any subscription item is set to active, including items from the free default Plan. |
| `subscription.pastDue` | The top-level subscription contains a subscription item that has become past due. |
## Subscription items
A subscription item provides details about the relationship between the payer (user or Organization) and a Plan. A top-level subscription may contain multiple subscription items.
There can only be one `active` subscription item per payer and Plan. In addition, the subscription item for the default Plan will always have the same `id` to allow easier tracking of which users and Organizations are not paid customers.
| Event Name | Description |
| - | - |
| `subscriptionItem.updated` | The subscription item is updated. This event is triggered when a property of the subscription item has changed that does not result in a status change. For example, when a subscription item is renewed and the recurring monthly charge succeeds, the status doesn't change (remains `active`), but `period_start` and `period_end` are updated. This results in a `subscriptionItem.updated` event. |
| `subscriptionItem.active` | The subscription item is set to active. For paid Plans, this happens on successful payment. |
| `subscriptionItem.canceled` | The subscription item is canceled. The payer retains Plan features until the end of the current billing period. |
| `subscriptionItem.upcoming` | The subscription item is set as upcoming after the current billing period. This can happen in the case of a deferred Plan change from a higher-priced to lower-priced Plan. In the case a paid Plan is canceled, the subscription item for the default, free Plan will be set as `upcoming`. |
| `subscriptionItem.ended` | The subscription item has ended. |
| `subscriptionItem.abandoned` | The subscription item is abandoned. This can happen to `upcoming` subscription items if the payer subscribes to another Plan, or re-subscribes to a currently canceled Plan. |
| `subscriptionItem.incomplete` | The subscription item is incomplete. This means the payer has started a checkout for a Plan, but the payment hasn't been successfully processed yet. Once payment succeeds, the subscription item transitions to an `active` status. |
| `subscriptionItem.pastDue` | The subscription item is past due because a recurring charge has failed. |
| `subscriptionItem.freeTrialEnding` | The subscription item is a free trial and is ending soon. This event is sent three days before the trial ends. If the trial is shorter than three days, it's sent immediately. |
## Payment attempts
Payment attempts allow you to track successful and failed payments, for both checkout and recurring charges.
Payment attempt events contain a `type`, which can be either `checkout` or `recurring`. You can use these values to determine whether a payment attempt was for a checkout or a subscription item renewal's recurring charge.
| Event Name | Description |
| - | - |
| `paymentAttempt.created` | A payment attempt has been created with `pending` status. It can either succeed or fail in the future. |
| `paymentAttempt.updated` | A payment attempt has been updated to `paid` or `failed` status. |
Looking for other webhook events? To find a list of all the events Clerk supports, navigate to the [**Webhooks**](https://dashboard.clerk.com/~/webhooks) page and select the **Event Catalog** tab.
---
title: Protect content and read user data
description: Learn how to use Clerk's hooks and helpers to protect content and
read user data in your Remix application.
metadata:
title: Read session and user data in your Remix app with Clerk
sdk: nextjs, expo, react-router, remix, tanstack-react-start, astro, nuxt
sdkScoped: "true"
canonical: /docs/:sdk:/guides/users/reading
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,expo,react-router,remix,tanstack-react-start,astro,nuxt
notAvailableSdks: react,js-frontend,chrome-extension,android,ios,expressjs,fastify,go,vue,ruby,js-backend
activeSdk: remix
sourceFile: /docs/guides/users/reading.remix.mdx
---
> \[!WARNING]
> The Remix SDK is in maintenance mode and will only receive security updates. Please migrate to the React Router SDK for continued development and new features.
Clerk provides a set of [hooks and helpers](/docs/reference/remix/overview) that you can use to protect content and read user data in your Remix application. Here are examples of how to use these helpers in both the client and server-side to get you started.
## Server-side
### `getAuth()`
The [`getAuth()`](/docs/reference/remix/overview#get-auth) helper allows you to access the Auth object, which includes the current user's `userId` and the `isAuthenticated` property, which can be used to protect your routes.
In the following example, the `userId` is passed to the JS Backend SDK's getUser() method to get the user's full `User` object. For information on how to use the JS Backend SDK, see the reference documentation.
```tsx {{ filename: 'routes/profile.tsx' }}
import { LoaderFunction, redirect } from '@remix-run/node'
import { getAuth } from '@clerk/remix/ssr.server'
import { createClerkClient } from '@clerk/remix/api.server'
export const loader: LoaderFunction = async (args) => {
// Use `getAuth()` to access `isAuthenticated` and the user's ID
const { isAuthenticated, userId } = await getAuth(args)
// Protect the route by checking if the user is signed in
if (!isAuthenticated) {
return redirect('/sign-in?redirect_url=' + args.request.url)
}
// Initialize the JS Backend SDK and get the user's full `Backend User` object
const user = await createClerkClient({ secretKey: process.env.CLERK_SECRET_KEY }).users.getUser(
userId,
)
// Return the retrieved user data
return { serialisedUser: JSON.stringify(user) }
}
```
```tsx {{ filename: 'routes/profile.tsx' }}
import { ActionFunction, redirect } from '@remix-run/node'
import { getAuth } from '@clerk/remix/ssr.server'
import { createClerkClient } from '@clerk/remix/api.server'
export const action: ActionFunction = async (args) => {
// Use `getAuth()` to access `isAuthenticated` and the user's ID
const { isAuthenticated, userId } = await getAuth(args)
// Protect the route by checking if the user is signed in
if (!isAuthenticated) {
return redirect('/sign-in?redirect_url=' + args.request.url)
}
// Initialize the JS Backend SDK and get the user's full `Backend User` object
const updatedUser = await createClerkClient({
secretKey: process.env.CLERK_SECRET_KEY,
}).users.getUser(userId)
// Return the retrieved user data
return { serialisedUser: JSON.stringify(updatedUser) }
}
```
## Client Side
### `useAuth()`
{/* TODO: Keep in sync with /tanstack-react-start/read-session-data and /expo/read-session-user-data */}
The following example uses the useAuth() hook to access the current auth state, as well as helper methods to manage the current session.
```tsx {{ filename: 'example.tsx' }}
export default function Example() {
const { isLoaded, isSignedIn, userId, sessionId, getToken } = useAuth()
const fetchExternalData = async () => {
// Use `getToken()` to get the current user's session token
const token = await getToken()
// Use `token` to fetch data from an external API
const response = await fetch('https://api.example.com/data', {
headers: {
Authorization: `Bearer ${token}`,
},
})
return response.json()
}
// Use `isLoaded` to check if Clerk is loaded
if (!isLoaded) {
return
Loading...
}
// Use `isSignedIn` to check if the user is signed in
if (!isSignedIn) {
// You could also add a redirect to the sign-in page here
return
Sign in to view this page
}
return (
Hello, {userId}! Your current active session is {sessionId}.
)
}
```
### `useUser()`
{/* TODO: Keep in sync with /reference/tanstack-react-start/read-session-data and /reference/expo/read-session-user-data */}
The following example uses the useUser() hook to access the User object, which contains the current user's data such as their full name. The following example demonstrates how to use `useUser()` to check if the user is signed in and display their first name.
```tsx {{ filename: 'src/Example.tsx' }}
export default function Example() {
const { isSignedIn, user, isLoaded } = useUser()
// Use `isLoaded` to check if Clerk is loaded
if (!isLoaded) {
return
Loading...
}
// Use `isSignedIn` to protect the content
if (!isSignedIn) {
return
Sign in to view this page
}
// Use `user` to access the current user's data
return
Hello {user.firstName}!
}
```
---
title: Component Reference
description: A list of Clerk's comprehensive suite of components designed to
seamlessly integrate authentication and multi-tenancy into your application.
sdk: react, nextjs, js-frontend, chrome-extension, expo, android, expressjs,
fastify, react-router, remix, tanstack-react-start, go, astro, nuxt, vue,
ruby, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/overview
lastUpdated: 2025-11-21T23:29:30.000Z
availableSdks: react,nextjs,js-frontend,chrome-extension,expo,android,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
notAvailableSdks: ios
activeSdk: remix
sourceFile: /docs/reference/components/overview.mdx
---
Clerk offers a comprehensive suite of components designed to seamlessly integrate authentication and multi-tenancy into your application. With Clerk components, you can easily customize the appearance of authentication components and pages, manage the entire authentication flow to suit your specific needs, and even build robust SaaS applications.
## Authentication components
* \
* \
* \
* \
* \
## User components
* \
* \
* \
## Organization components
* \
* \
* \
* \
## Billing components
* \
* \
* \
* \
## Control components
Control components manage authentication-related behaviors in your application. They handle tasks such as controlling content visibility based on user authentication status, managing loading states during authentication processes, and redirecting users to appropriate pages. Control components render at `` and `` states for assertions on the Clerk object. A common example is the \ component, which allows you to conditionally render content only when a user is authenticated.
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
## Unstyled components
* \
* \
* \
* \
## Customization guides
* [Customize components with the `appearance` prop](/docs/guides/customizing-clerk/appearance-prop/overview)
* [Localize components with the `localization` prop (experimental)](/docs/guides/customizing-clerk/localization)
* [Add pages to the `` component](/docs/guides/customizing-clerk/adding-items/user-profile)
* [Add pages to the `` component](/docs/guides/customizing-clerk/adding-items/organization-profile)
### Secured by Clerk branding
> \[!WARNING]
> This feature requires a [paid plan](/pricing){{ target: '_blank' }} for production use, but all features are free to use in development mode so that you can try out what works for you. See the [pricing](/pricing){{ target: '_blank' }} page for more information.
By default, Clerk displays a **Secured by Clerk** badge on Clerk components. You can remove this branding by following these steps:
1. In the Clerk Dashboard, navigate to your application's [**Settings**](https://dashboard.clerk.com/~/settings).
2. Under **Branding**, toggle on the **Remove "Secured by Clerk" branding** option.
* [Join our Discord](https://clerk.com/discord "Join Discord")
* Join our official Discord server to chat with us directly and become a part of the Clerk community.
* {}
***
* [Need help?](/support "Get help")
* Contact us through Discord, Twitter, or email to receive answers to your questions and learn more about Clerk.
* {}
---
title: "`` component"
description: Clerk's component renders a UI for authenticating
users with Google's One Tap API.
sdk: astro, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/authentication/google-one-tap
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: chrome-extension,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/authentication/google-one-tap.mdx
---
> \[!IMPORTANT]
> To use Google One Tap with Clerk, you must [enable Google as a social connection in the Clerk Dashboard](/docs/guides/configure/auth-strategies/social-connections/google#configure-for-your-production-instance) and make sure to use custom credentials.
The `` component renders the [Google One Tap](https://developers.google.com/identity/gsi/web/guides/features) UI so that users can use a single button to sign-up or sign-in to your Clerk application with their Google accounts.
By default, this component will redirect users back to the page where the authentication flow started. However, you can override this with force redirect URL props or [force redirect URL environment variables](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects).
> \[!TIP]
> `` does not render if the user is already signed into your Clerk application, so there's no need to manually check if a user is signed in yourself before rendering it.
## Example
The following example includes basic implementation of the `` component. You can use this as a starting point for your own implementation.
```tsx {{ filename: 'app/routes/sign-in.tsx' }}
import { GoogleOneTap } from '@clerk/remix'
export default function Page() {
return
}
```
## Properties
* `cancelOnTapOutside?`
* `boolean`
If `true`, the One Tap prompt closes automatically if the user clicks outside of the prompt. Defaults to `true`.
***
* `itpSupport?`
* `boolean`
If `true`, enables the [ITP-specific UX](https://developers.google.com/identity/gsi/web/guides/itp) when One Tap is rendered on ITP browsers such as Chrome on iOS, Safari, and FireFox. Defaults to `true`.
***
* `fedCmSupport?`
* `boolean`
If `true`, enables Google One Tap to use [the FedCM API](https://developers.google.com/privacy-sandbox/3pcd/fedcm) to sign users in. See Google's docs on [best practices when disabling FedCM support](https://developers.google.com/identity/gsi/web/guides/display-google-one-tap#do_not_cover_google_one_tap). Defaults to `true`
***
* `signInForceRedirectUrl?`
* `string`
Useful if you want to redirect to a path specific to Google One Tap users. If provided, this URL will **always** be redirected to after the user signs in, overriding any \ redirect URL props or [redirect URL environment variables](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects).
***
* `signUpForceRedirectUrl?`
* `string`
Useful if you want to redirect to a path specific to Google One Tap users. If provided, this URL will **always** be redirected to after the user signs up, overriding any \ redirect URL props or [redirect URL environment variables](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects).
## Limitations
* If your application will use the Google API on behalf of your users, the `` component is not recommended, as Google does not provide Clerk with an access or refresh token that you can use.
* Users with the 1Password browser extension may not be able to render the Google One Tap UI. They must disable this extension.
* When testing in development, if you select the `X` button to close the Google One Tap UI, you may encounter [a cooldown](https://developers.google.com/identity/gsi/web/guides/features#exponential_cooldown) that prevents you from rendering it again for a period of time. To bypass the cooldown, remove the `g_state` cookie.
---
title: "`` component"
description: Clerk's component renders a UI for signing in users.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/authentication/sign-in
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/authentication/sign-in.mdx
---
{{ style: { maxWidth: '460px' } }}
The `` component renders a UI to allow users to sign in or sign up by default. The functionality of the `` component is controlled by the instance settings you specify in the [Clerk Dashboard](https://dashboard.clerk.com), such as [sign-in and sign-up options](/docs/guides/configure/auth-strategies/sign-up-sign-in-options) and [social connections](/docs/guides/configure/auth-strategies/social-connections/all-providers). You can further customize your `` component by passing additional properties at the time of rendering.
> \[!NOTE]
> The `` and `` components cannot render when a user is already signed in, unless the application allows multiple sessions. If a user is already signed in and the application only allows a single session, Clerk will redirect the user to the Home URL instead.
## Example
The following example includes basic implementation of the `` component. You can use this as a starting point for your own implementation.
If you would like to create a dedicated `/sign-in` page in your Remix application, there are a few requirements you must follow. See the [dedicated guide](/docs/remix/guides/development/custom-sign-in-or-up-page) for more information.
```tsx {{ filename: 'app/routes/sign-in.$.tsx' }}
import { SignIn } from '@clerk/remix'
export default function SignInPage() {
return
}
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `fallbackRedirectUrl`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `forceRedirectUrl`
* `string`
If provided, this URL will always be redirected to after the user signs in. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `initialValues`
* SignInInitialValues
The values used to prefill the sign-in fields with.
***
* `oauthFlow`
* `"redirect" | "popup" | "auto"`
Determines how OAuth authentication is performed. Accepts the following properties:
* `"redirect"`: Redirect to the OAuth provider on the current page.
* `"popup"`: Open a popup window.
* `"auto"`: Choose the best method based on whether the current domain typically requires the `"popup"` flow to correctly perform authentication.
Defaults to `"auto"`.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash-based routing. For example: `/sign-in`.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
***
* `signUpFallbackRedirectUrl`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Used for the 'Don't have an account? Sign up' link that's rendered. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpForceRedirectUrl`
* `string`
If provided, this URL will always used as the redirect destination after the user signs up. Used for the 'Don't have an account? Sign up' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpUrl`
* `string`
The full URL or path to the sign-up page. Used for the 'Don't have an account? Sign up' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `transferable`
* `boolean`
Indicates whether or not sign in attempts are transferable to the sign up flow. Defaults to `true`. When set to `false`, prevents opaque sign ups when a user attempts to sign in via OAuth with an email that doesn't exist.
***
* `waitlistUrl`
* `string`
Full URL or path to the waitlist page. Use this property to provide the target of the 'Waitlist' link that's rendered. If `undefined`, will redirect to the [Account Portal waitlist page](/docs/guides/customizing-clerk/account-portal#waitlist). If you've passed the `waitlistUrl` prop to the \ component, it will infer from that, and you can omit this prop.
***
* `withSignUp`
* `boolean`
Opt into sign-in-or-up flow by setting this prop to `true`. When `true`, if a user does not exist, they will be prompted to sign up. If a user exists, they will be prompted to sign in. Defaults to `true` if the `CLERK_SIGN_IN_URL` environment variable is set. Otherwise, defaults to `false`.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
If Clerk's prebuilt components don't meet your specific needs or if you require more control over the logic, you can rebuild the existing Clerk flows using the Clerk API. For more information, see the [custom flow guides](/docs/guides/development/custom-flows/overview).
---
title: "`` component"
description: Clerk's component renders a UI for signing up users.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/authentication/sign-up
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/authentication/sign-up.mdx
---
{{ style: { maxWidth: '460px' } }}
The `` component renders a UI for signing up users. The functionality of the `` component is controlled by the instance settings you specify in the [Clerk Dashboard](https://dashboard.clerk.com), such as [sign-in and sign-up options](/docs/guides/configure/auth-strategies/sign-up-sign-in-options) and [social connections](/docs/guides/configure/auth-strategies/social-connections/all-providers). You can further customize your `` component by passing additional properties at the time of rendering.
> \[!NOTE]
> The `` and `` components cannot render when a user is already signed in, unless the application allows multiple sessions. If a user is already signed in and the application only allows a single session, Clerk will redirect the user to the Home URL instead.
## Example
The following example includes basic implementation of the `` component. You can use this as a starting point for your own implementation.
If you would like to create a dedicated `/sign-up` page in your Remix application, there are a few requirements you must follow. See the [dedicated guide](/docs/remix/guides/development/custom-sign-up-page) for more information.
```tsx {{ filename: 'app/routes/sign-up.$.tsx' }}
import { SignUp } from '@clerk/remix'
export default function SignUpPage() {
return
}
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `fallbackRedirectUrl`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `forceRedirectUrl`
* `string`
If provided, this URL will always be used as the redirect destination after the user signs up. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `initialValues`
* SignUpInitialValues
The values used to prefill the sign-up fields with.
***
* `oauthFlow`
* `"redirect" | "popup" | "auto"`
Determines how OAuth authentication is performed. Accepts the following properties:
* `"redirect"`: Redirect to the OAuth provider on the current page.
* `"popup"`: Open a popup window.
* `"auto"`: Choose the best method based on whether the current domain typically requires the `"popup"` flow to correctly perform authentication.
Defaults to `"auto"`.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash-based routing. For example: `/sign-up`.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
***
* `signInFallbackRedirectUrl`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Used for the 'Already have an account? Sign in' link that's rendered. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signInForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs in. Used for the 'Already have an account? Sign in' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signInUrl`
* `string`
The full URL or path to the sign-in page. Used for the 'Already have an account? Sign in' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `unsafeMetadata`
* SignUpUnsafeMetadata
Metadata that can be read and set from the frontend and the backend. Once the sign-up is complete, the value of this field will be automatically copied to the created user's unsafe metadata (`User.unsafeMetadata`). One common use case is to collect custom information about the user during the sign-up process and store it in this property. Read more about [unsafe metadata](/docs/guides/users/extending#unsafe-metadata).
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
If Clerk's prebuilt components don't meet your specific needs or if you require more control over the logic, you can rebuild the existing Clerk flows using the Clerk API. For more information, see the [custom flow guides](/docs/guides/development/custom-flows/overview).
---
title: "`` component"
description: Clerk's component renders a UI for
resolving the `choose-organization` task.
sdk: js-frontend, nextjs, react, react-router, remix, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/authentication/task-choose-organization
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: js-frontend,nextjs,react,react-router,remix,tanstack-react-start
notAvailableSdks: chrome-extension,expo,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/authentication/task-choose-organization.mdx
---
{{ style: { maxWidth: '460px' } }}
The `` component renders a UI for resolving the `choose-organization` session task. The functionality of the `` component is controlled by the instance settings you specify in the [Clerk Dashboard](https://dashboard.clerk.com), such as [sign-in and sign-up options](/docs/guides/configure/auth-strategies/sign-up-sign-in-options) and [social connections](/docs/guides/configure/auth-strategies/social-connections/overview). You can further customize your `` component by passing additional properties at the time of rendering.
> \[!IMPORTANT]
> The `` component cannot render when a user doesn't have current session tasks.
## Example
The following example demonstrates how to host the `` component on a custom page.
```tsx {{ filename: 'app/root.tsx', fold: [[1, 37]], mark: [39] }}
import type { MetaFunction, LoaderFunction } from '@remix-run/node'
import { Links, Meta, Outlet, Scripts, ScrollRestoration } from '@remix-run/react'
import { rootAuthLoader } from '@clerk/remix/ssr.server'
import { ClerkApp } from '@clerk/remix'
export const meta: MetaFunction = () => [
{
charset: 'utf-8',
title: 'New Remix App',
viewport: 'width=device-width,initial-scale=1',
},
]
export const loader: LoaderFunction = (args) => rootAuthLoader(args)
export function Layout({ children }: { children: React.ReactNode }) {
return (
{children}
)
}
function App() {
return
}
export default ClerkApp(App, {
taskUrls: { 'choose-organization': '/onboarding/choose-organization' },
})
```
The `` component must be used in conjunction with the `` component. See the [dedicated guide on how to self-host the `` component](/docs/remix/guides/development/custom-sign-in-or-up-page).
```tsx {{ filename: 'app/routes/onboarding.choose-organization.tsx' }}
import { TaskChooseOrganization } from '@clerk/remix'
export default function ChooseOrganizationPage() {
return
}
```
## Properties
All props are optional.
* `redirectUrlComplete`
* `string`
The full URL or path to navigate to after successfully completing all tasks.
***
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
If Clerk's prebuilt components don't meet your specific needs or if you require more control over the logic, you can rebuild the existing Clerk flows using the Clerk API. For more information, see the [custom flow guides](/docs/guides/development/custom-flows/overview).
---
title: "`` component"
description: The component renders a waitlist form that allows
users to join for early access to your application.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/authentication/waitlist
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/authentication/waitlist.mdx
---
{{ style: { maxWidth: '460px' } }}
In **Waitlist** mode, users can register their interest in your app by joining a waitlist. This mode is ideal for apps in early development stages or those wanting to generate interest before launch. [Learn more about additional features available in **Waitlist** mode](/docs/guides/secure/restricting-access#waitlist).
The `` component renders a form that allows users to join for early access to your app.
## Enable Waitlist mode
Before using the `` component, you must enable **Waitlist** mode in the Clerk Dashboard:
1. In the Clerk Dashboard, navigate to the [**Restrictions**](https://dashboard.clerk.com/~/user-authentication/restrictions) page.
2. Under the **Sign-up modes** section, enable **Waitlist**.
## Example
> \[!WARNING]
> Before using the `` component, you must provide the `waitlistUrl` prop either in the \ or \ component to ensure proper functionality.
The following example includes a basic implementation of the `` component. You can use this as a starting point for your own implementation.
```tsx {{ filename: 'app/routes/waitlist.tsx' }}
import { Waitlist } from '@clerk/remix'
export default function WaitlistPage() {
return
}
```
## Properties
All props are optional.
* `afterJoinWaitlistUrl`
* `string`
The full URL or path to navigate to after joining the waitlist.
***
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `signInUrl`
* `string`
The full URL or path to the sign in page. Used for the 'Already have an account? Sign in' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
## Customization
To learn about how to customize Clerk components, see the [customization guide](/docs/guides/customizing-clerk/appearance-prop/overview).
---
title: "``"
description: Clerk's component displays a table of Plans and
Features that users can subscribe to.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/billing/pricing-table
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/billing/pricing-table.mdx
---

The `` component displays a table of Plans and Features that users can subscribe to.
## Example
The following example includes a basic implementation of the `` component. You can use this as a starting point for your own implementation.
```tsx {{ filename: 'app/routes/pricing.tsx' }}
import { PricingTable } from '@clerk/remix'
export default function PricingPage() {
return
}
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `checkoutProps`
* `{ appearance: Appearance }`
Options for the checkout drawer. Accepts the following properties:
* [`appearance`](/docs/guides/customizing-clerk/appearance-prop/overview): an object used to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `collapseFeatures`
* `boolean`
A boolean that indicates whether the Features are collapsed. **Requires `layout` to be set to `'default'`**. Defaults to `false`.
***
* `ctaPosition`
* `'top' | 'bottom'`
The placement of the CTA button. **Requires `layout` to be set to `'default'`**. Defaults to `'bottom'`.
***
* `fallback`
* `JSX`
An optional UI to show when the pricing table is loading.
***
* `for`
* `'user' | 'organization'`
A string that indicates whether the pricing table is for users or [Organizations](/docs/guides/organizations/overview). If `'user'`, the pricing table will display a list of Plans and Features that **users** can subscribe to. If `'organization'`, the pricing table will display a list of Plans and Features that **Organizations** can subscribe to. Defaults to `'user'`.
***
* `newSubscriptionRedirectUrl`
* `string`
The URL to navigate to after the user completes the checkout and selects the "Continue" button.
---
title: \RedirectCallback />
description: Clerk's `` component is used to
implement custom OAuth flows. It handles the OAuth callback and completes the
authentication process.
sdk: astro, chrome-extension, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/authenticate-with-redirect-callback
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: expo,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/control/authenticate-with-redirect-callback.mdx
---
The `` component is a crucial part of implementing custom OAuth flows in your application. It serves as the callback handler for the authentication process initiated by the `authenticateWithRedirect()` method. Render it on the route specified as the `redirectUrl` in your `authenticateWithRedirect()` call.
This component automatically handles the OAuth callback, completing the authentication process and managing the user's session. It uses the handleRedirectCallback() method under the hood.
## Example
For an example of how to use the `` component, see the [custom flow](/docs/guides/development/custom-flows/authentication/oauth-connections) guide.
## Properties
All props are optional.
* `continueSignUpUrl?`
* `string | undefined | null`
The full URL or path to navigate to if the sign up requires additional information.
***
* `signInUrl?`
* `string`
The full URL or path where the `` component is mounted.
***
* `signUpUrl?`
* `string`
The full URL or path where the `` component is mounted.
***
* `signInFallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpFallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signInForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs in. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs up. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `firstFactorUrl?`
* `string | undefined`
The full URL or path to navigate to during sign in, if first factor verification is required.
***
* `secondFactorUrl?`
* `string | undefined`
The full URL or path to navigate to during sign in, if [multi-factor authentication](/docs/guides/configure/auth-strategies/sign-up-sign-in-options#multi-factor-authentication) is enabled.
***
* `resetPasswordUrl?`
* `string`
The full URL or path to navigate to during sign in, if the user is required to reset their password.
***
* `transferable?`
* `boolean`
A boolean that indicates whether or not sign in attempts are transferable to the sign up flow. Defaults to `true`. When set to `false`, prevents opaque sign ups when a user attempts to sign in via OAuth with an email that doesn't exist.
***
* `verifyEmailAddressUrl?`
* `string | undefined | null`
The full URL or path to navigate to after requesting email verification.
***
* `verifyPhoneNumberUrl?`
* `string | undefined | null`
The full URL or path to navigate to after requesting phone verification.
---
title: "``"
description: The component indicates that Clerk is partially operational.
sdk: nextjs, react, react-router, chrome-extension, remix, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/clerk-degraded
lastUpdated: 2025-11-21T22:25:46.000Z
availableSdks: nextjs,react,react-router,chrome-extension,remix,tanstack-react-start
notAvailableSdks: js-frontend,expo,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/control/clerk-degraded.mdx
---
The `` component indicates that Clerk is partially operational.
## Example
It's not recommended to wrap the entire app in control components; instead, only wrap the components that need access to the `Clerk` object, such as custom flowsA **custom flow** refers to a user interface built entirely from scratch using the Clerk API. Learn more about [custom flows](/docs/guides/development/custom-flows/overview)..
```tsx {{ filename: 'app/routes/_index.tsx' }}
import { ClerkLoading, ClerkLoaded, ClerkDegraded, ClerkFailed } from '@clerk/remix'
export default function Index() {
return (
<>
Clerk is loading...
Clerk has loaded (ready or degraded)
Clerk is experiencing issues. Please try again later.
Something went wrong with Clerk. Please contact support.
>
)
}
```
---
title: "``"
description: The component indicates that the Clerk object has failed to load.
sdk: nextjs, react, react-router, chrome-extension, remix, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/clerk-failed
lastUpdated: 2025-11-21T22:25:46.000Z
availableSdks: nextjs,react,react-router,chrome-extension,remix,tanstack-react-start
notAvailableSdks: js-frontend,expo,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/control/clerk-failed.mdx
---
The `` component indicates that the Clerk object has failed to load. This is useful for displaying an error message to the user.
## Example
It's not recommended to wrap the entire app in control components; instead, only wrap the components that need access to the `Clerk` object, such as custom flowsA **custom flow** refers to a user interface built entirely from scratch using the Clerk API. Learn more about [custom flows](/docs/guides/development/custom-flows/overview)..
```tsx {{ filename: 'app/routes/_index.tsx' }}
import { ClerkLoading, ClerkLoaded, ClerkDegraded, ClerkFailed } from '@clerk/remix'
export default function Index() {
return (
<>
Clerk is loading...
Clerk has loaded (ready or degraded)
Clerk is experiencing issues. Please try again later.
Something went wrong with Clerk. Please contact support.
>
)
}
```
---
title: "``"
description: The `` component guarantees that the Clerk object has
loaded and will be available under `window.Clerk`. This allows you to wrap
child components to access the Clerk object without the need to check it
exists.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/clerk-loaded
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/control/clerk-loaded.mdx
---
The `` component guarantees that the Clerk object has loaded (the `status` is `'ready'` or `'degraded'`) and will be available under `window.Clerk`. This allows you to wrap child components to access the `Clerk` object without the need to check it exists.
## Example
It's not recommended to wrap the entire app in the `` component; instead, only wrap the components that need access to the `Clerk` object.
```tsx {{ filename: 'app/routes/_index.tsx' }}
import { ClerkLoading, ClerkLoaded, ClerkDegraded, ClerkFailed } from '@clerk/remix'
export default function Index() {
return (
<>
Clerk is loading...
Clerk has loaded (ready or degraded)
Clerk is experiencing issues. Please try again later.
Something went wrong with Clerk. Please contact support.
>
)
}
```
---
title: "``"
description: The `` renders its children while Clerk is loading,
and is helpful for showing a custom loading state.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/clerk-loading
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/control/clerk-loading.mdx
---
The `` renders its children while Clerk is loading, and is helpful for showing a custom loading state.
## Example
It's not recommended to wrap the entire app in the `` component; instead, only wrap the components that need access to the `Clerk` object.
```tsx {{ filename: 'app/routes/_index.tsx' }}
import { ClerkLoading, ClerkLoaded, ClerkDegraded, ClerkFailed } from '@clerk/remix'
export default function Index() {
return (
<>
Clerk is loading...
Clerk has loaded (ready or degraded)
Clerk is experiencing issues. Please try again later.
Something went wrong with Clerk. Please contact support.
>
)
}
```
---
title: "``"
description: The Protect component protects content or even entire routes based
on authentication, and optionally, authorization. It only renders its children
when the current user is signed-in, and if performing authorization checks, if
the user has been granted a specific type of access control (Role, Permission,
Feature, or Plan).
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/protect
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/control/protect.mdx
---
The \ component protects content or even entire routes based on:
* authentication: whether the user is signed-in or not.
* authorization: whether the user has been granted a specific type of access control (Role, Permission, Feature, or Plan)
`` **always** performs authentication checks. To perform authorization checksAuthorization checks are checks you perform in your code to determine the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions or access certain content. Learn more about [authorization checks](/docs/guides/secure/authorization-checks)., you can pass different props, like `role`, `permission`, `feature`, or `plan`.
`` accepts a `fallback` prop that will be rendered if the user fails the authentication or authorization checks.
`` can be used both client-side and server-side (in Server Components).
> \[!CAUTION]
> This component only **visually hides** its children when the current user is not authorized. The contents of its children remain accessible via the browser's source code even if the user fails the authorization check. Do not use this component to hide sensitive information that should be completely inaccessible to unauthorized users. For truly sensitive data, perform authorization checksAuthorization checks are checks you perform in your code to determine the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions or access certain content. Learn more about [authorization checks](/docs/guides/secure/authorization-checks). on the server before sending the data to the client.
## Usage
### Authentication checks
`` always performs authentication checks. It will render its children if the user is signed-in, and its `fallback` prop if the user is signed-out.
```tsx {{ filename: 'app/routes/dashboard.tsx' }}
import { Protect } from '@clerk/remix'
export default function DashboardPage() {
return (
Users that are signed-out can see this.}>
Users that are signed-in can see this.
)
}
```
### Authorization checks
To limit who is able to see the content that `` renders, you can pass **one** of the access control props: `permission`, `role`, `feature`, or `plan`. It's recommended to use **Permission-based** authorization over **Role-based** authorization, and **Feature-based** authorization over **Plan-based** authorization, as they are more flexible, easier to manage, and more secure.
If you do not pass any of the access control props, `` will render its children if the user is signed in, regardless of their Role or its Permissions.
For more complex authorization logic, pass conditional logic to the `condition` prop.
### Render content by Permissions
The following example demonstrates how to use the `` component to protect content by checking if the user has the `org:invoices:create` Permission.
```tsx {{ filename: 'app/routes/invoices.tsx' }}
import { Protect } from '@clerk/remix'
export default function InvoicesPage() {
return (
You do not have the Permissions to create an invoice.}
>
Users with Permission org:invoices:create can see this.
)
}
```
### Render content by Role
While authorization by `permission` is **recommended**, for convenience, `` allows a `role` prop to be passed.
The following example demonstrates how to use the `` component to protect content by checking if the user has the `org:billing` Role.
```tsx {{ filename: 'app/routes/billing.tsx' }}
import { Protect } from '@clerk/remix'
export default function BillingPage() {
return (
Only a member of the Billing department can access this content.}
>
Users with Role org:billing can see this.
)
}
```
### Render content by Plan
The following example demonstrates how to use `` to protect content by checking if the user has a Plan.
```tsx {{ filename: 'app/routes/bronze.tsx' }}
import { Protect } from '@clerk/remix'
export default function BronzePage() {
return (
Sorry, only subscribers to the Bronze plan can access this content.}
>
Welcome, Bronze subscriber!
)
}
```
### Render content by Feature
The following example demonstrates how to use `` to protect content by checking if the user has a Feature.
```tsx {{ filename: 'app/routes/premium-access.tsx' }}
import { Protect } from '@clerk/remix'
export default function PremiumAccessPage() {
return (
Sorry, only subscribers with the Premium Access feature can access this content.
}
>
Congratulations! You have access to the Premium Access feature.
)
}
```
### Render content conditionally
The following example uses ``'s `condition` prop to conditionally render its children if the user has the correct Role.
```tsx {{ filename: 'app/routes/settings.tsx' }}
import { Protect } from '@clerk/remix'
export default function SettingsPage() {
return (
has({ role: 'org:admin' }) || has({ role: 'org:billing_manager' })}
fallback={
Only an Admin or Billing Manager can access this content.
}
>
The settings page.
)
}
```
## Properties
* `condition?`
* `has => boolean`
Optional conditional logic that renders the children if it returns `true`.
***
* `fallback?`
* `JSX`
Optional UI to show when a user doesn't have the correct type of access control to access the protected content.
***
* `feature?`
* `string`
Optional string corresponding to a [Feature](/docs/guides/billing/overview).
***
* `plan?`
* `string`
Optional string corresponding to a [Plan](/docs/guides/billing/overview).
***
* `permission?`
* `string`
Optional string corresponding to a [Permission](/docs/guides/organizations/roles-and-permissions) in the format `org::`
***
* `role?`
* `string`
Optional string corresponding to a [Role](/docs/guides/organizations/roles-and-permissions) in the format `org:`
***
* `treatPendingAsSignedOut?`
* `boolean`
A boolean that indicates whether to treat pending sessions as signed out. Defaults to `true`.
---
title: "`` (deprecated)"
description: The component will navigate to the
create Organization flow which has been configured in your application
instance. The behavior will be just like a server-side (3xx) redirect, and
will override the current location in the history stack.
sdk: nextjs, nuxt, react, react-router, remix, tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/redirect-to-create-organization
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/control/redirect-to-create-organization.mdx
---
> \[!WARNING]
> This feature is deprecated. Please use the redirectToCreateOrganization() method instead.
The `` component will navigate to the create Organization flow which has been configured in your application instance. The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.
## Example
```tsx {{ filename: 'app/routes/_index.tsx' }}
import { SignedIn, SignedOut, RedirectToCreateOrganization } from '@clerk/remix'
export default function Index() {
return (
You need to sign in to create an Organization.
)
}
```
---
title: "`` (deprecated)"
description: The component will navigate to
the Organization profile URL which has been configured in your application
instance. The behavior will be just like a server-side (3xx) redirect, and
will override the current location in the history stack.
sdk: nextjs, nuxt, react, react-router, remix, tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/redirect-to-organization-profile
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/control/redirect-to-organization-profile.mdx
---
> \[!WARNING]
> This feature is deprecated. Please use the redirectToOrganizationProfile() method instead.
The `` component will navigate to the Organization profile URL which has been configured in your application instance. The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.
## Example
```tsx {{ filename: 'app/routes/_index.tsx' }}
import { SignedIn, SignedOut, RedirectToOrganizationProfile } from '@clerk/remix'
export default function Index() {
return (
You need to sign in to view your Organization profile.
)
}
```
---
title: "``"
description: The component will navigate to the sign in URL
which has been configured in your application instance. The behavior will be
just like a server-side (3xx) redirect, and will override the current location
in the history stack.
sdk: chrome-extension, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/redirect-to-sign-in
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: chrome-extension,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,expo,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/control/redirect-to-sign-in.mdx
---
The `` component will navigate to the sign in URL which has been configured in your application instance. The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.
## Example
```tsx {{ filename: 'app/routes/_index.tsx' }}
import { SignedIn, SignedOut, RedirectToSignIn, UserButton } from '@clerk/remix'
export default function Index() {
return (
)
}
```
---
title: "`` (deprecated)"
description: The component will navigate to the user
profile URL which has been configured in your application instance. The
behavior will be just like a server-side (3xx) redirect, and will override the
current location in the history stack.
sdk: nextjs, nuxt, react, react-router, remix, tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/redirect-to-user-profile
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/control/redirect-to-user-profile.mdx
---
> \[!WARNING]
> This feature is deprecated. Please use the redirectToUserProfile() method instead.
The `` component will navigate to the Account Portal User Profile URL which has been configured in your application instance. The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.
To find your User Profile URL:
1. In the Clerk Dashboard, navigate to the [**Account Portal**](https://dashboard.clerk.com/~/account-portal) page.
2. Under **User profile**, select the **Visit** icon.
## Example
```tsx {{ filename: 'app/routes/_index.tsx' }}
import { SignedIn, SignedOut, RedirectToUserProfile } from '@clerk/remix'
export default function Index() {
return (
You need to sign in to view your user profile.
)
}
```
---
title: "``"
description: The component will navigate to the sign up URL
which has been configured in your application instance. The behavior will be
just like a server-side (3xx) redirect, and will override the current location
in the history stack.
sdk: chrome-extension, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/redirect-to-sign-up
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: chrome-extension,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,expo,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/control/redirect-to-sign-up.mdx
---
The `` component will navigate to the sign up URL which has been configured in your application instance. The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.
## Example
```tsx {{ filename: 'app/routes/_index.tsx' }}
import { SignedIn, SignedOut, RedirectToSignUp, UserButton } from '@clerk/remix'
export default function Index() {
return (
)
}
```
---
title: "``"
description: Conditionally render content only when a user is signed in.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/signed-in
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/control/signed-in.mdx
---
## Overview
The `` component offers authentication checks as a cross-cutting concern. Any children components wrapped by a `` component will be rendered only if there's a user with an active session signed in your application.
> \[!CAUTION]
> This component only **visually hides** its children when the current user is not authenticated. The contents of its children remain accessible via the browser's source code even if the user fails the authentication check. Do not use this component to hide sensitive information that should be completely inaccessible to unauthorized users. For truly sensitive data, perform authorization checksAuthorization checks are checks you perform in your code to determine the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions or access certain content. Learn more about [authorization checks](/docs/guides/secure/authorization-checks). on the server before sending the data to the client.
## Example
```tsx {{ filename: 'app/routes/_index.tsx' }}
import { SignedIn } from '@clerk/remix'
export default function Index() {
return (
You are signed in.
This content is always visible.
)
}
```
## Properties
* `treatPendingAsSignedOut?`
* `boolean`
A boolean that indicates whether to treat pending sessions as signed out. Defaults to `true`.
---
title: "``"
description: Conditionally render content only when a user is signed out.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/signed-out
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/control/signed-out.mdx
---
The `` component offers authentication checks as a cross-cutting concern. Any child nodes wrapped by a `` component will be rendered only if there's no User signed in to your application.
## Example
```tsx {{ filename: 'app/routes/_index.tsx' }}
import { SignedOut } from '@clerk/remix'
export default function Index() {
return (
You are signed out.
This content is always visible.
)
}
```
## Properties
* `treatPendingAsSignedOut?`
* `boolean`
A boolean that indicates whether to treat pending sessions as signed out. Defaults to `true`.
---
title: "`` component"
description: Clerk's component is used to render an
Organization creation UI that allows users to create brand new Organizations
within your application.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/organization/create-organization
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/organization/create-organization.mdx
---
{{ style: { maxWidth: '492px' } }}
The `` component is used to render an Organization creation UI that allows users to create brand new Organizations in your application.
## Example
The following example includes a basic implementation of the `` component. You can use this as a starting point for your own implementation.
```tsx {{ filename: 'app/routes/create-organization.tsx' }}
import { CreateOrganization } from '@clerk/remix'
export default function CreateOrganizationPage() {
return
}
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `afterCreateOrganizationUrl`
* `string`
Full URL or path to navigate to after creating a new organization.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash-based routing. For example: `/create-organization`.
***
* `skipInvitationScreen`
* `boolean`
Hides the screen for sending invitations after an Organization is created. When left undefined, Clerk will automatically hide the screen if the number of max allowed members is equal to 1
***
* `hideSlug`
* `boolean`
Hides the optional slug field in the Organization creation screen.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
---
title: "`` component"
description: Clerk's component is used to display
Organization related memberships, invitations, and suggestions for the user.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/organization/organization-list
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/organization/organization-list.mdx
---
{{ style: { maxWidth: '460px' } }}
The `` component displays Organization-related memberships and automatic [invitations](/docs/guides/organizations/verified-domains#automatic-invitations) and [suggestions](/docs/guides/organizations/verified-domains#automatic-suggestions) for the user.
## Example
```tsx {{ filename: 'app/routes/organizations.tsx' }}
import { OrganizationList } from '@clerk/remix'
export default function OrganizationListPage() {
return (
`/organization/${org.slug}`}
afterSelectPersonalUrl={(user) => `/user/${user.id}`}
afterSelectOrganizationUrl={(org) => `/organization/${org.slug}`}
/>
)
}
```
## Properties
The `` component accepts the following properties, all of which are **optional**:
* `afterCreateOrganizationUrl`
* ((org: Organization) => string) | string
The full URL or path to navigate to after creating a new Organization.
***
* `afterSelectOrganizationUrl`
* ((org: Organization) => string) | string
The full URL or path to navigate to after selecting an Organization. Defaults to `undefined`.
***
* `afterSelectPersonalUrl`
* ((org: Organization) => string) | string
The full URL or path to navigate to after selecting the [Personal Account](/docs/guides/organizations/overview#allow-personal-accounts). Defaults to `undefined`.
***
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `hidePersonal`
* `boolean`
A boolean that controls whether `` will include the user's [Personal Account](/docs/guides/organizations/overview#allow-personal-accounts) in the Organization list. Setting this to `true` will hide the Personal Account option, and users will only be able to switch between Organizations. Defaults to `false`.
***
* `hideSlug`
* `boolean`
A boolean that controls whether the optional slug field in the Organization creation screen is hidden. Defaults to `false`.
***
* `skipInvitationScreen`
* `boolean | undefined`
A boolean that controls whether the screen for sending invitations after an Organization is created is hidden. When `undefined`, Clerk will automatically hide the screen if the number of max allowed members is equal to 1. Defaults to `false`.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
[org-ref]: /docs/reference/javascript/organization
---
title: "`` component"
description: Clerk's component is used to render a
beautiful, full-featured Organization management UI that allows users to
manage their Organization profile and security settings.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/organization/organization-profile
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/organization/organization-profile.mdx
---

The `` component allows users to manage their Organization membership, security, and billing settings.
This component's **General** tab displays the Organization's information and the **Leave organization** button. Admins will be able to see the **Update profile** button, **Verified domains** section, and **Delete organization** button.
The **Members** tab shows the Organization's members along with their join dates and Roles. Admins will have the ability to invite a member, change a member's Role, or remove them from the Organization. Admins will have tabs within the **Members** tab to view the Organization's [invitations](/docs/guides/organizations/overview#organization-invitations) and [requests](/docs/guides/organizations/verified-domains#membership-requests).
The **Billing** tab displays the Plans and Features that are available to the Organization, as well as the user's billing information, such as their invoices and payment methods.
## Example
```tsx {{ filename: 'app/routes/organization-profile.tsx' }}
import { OrganizationProfile } from '@clerk/remix'
export default function OrganizationProfilePage() {
return
}
```
## Properties
The `` component accepts the following properties, all of which are **optional**:
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `afterLeaveOrganizationUrl`
* `string`
The full URL or path to navigate to after leaving an Organization.
***
* `customPages`
* `CustomPages[]`
An array of custom pages to add to the Organization profile. Only available for the JavaScript SDK. To add custom pages with React-based SDK's, see the [dedicated guide](/docs/guides/customizing-clerk/adding-items/organization-profile).
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash- and virtual-based routing. For example: `/organization-profile`.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
In addition, you also can add custom pages and links to the `` navigation sidenav. For more information, refer to the [Custom Pages](/docs/guides/customizing-clerk/adding-items/organization-profile) documentation.
---
title: "`` component"
description: Clerk's component is used to enable the
ability to switch between available Organizations the user may be part of in
your application.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/organization/organization-switcher
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/organization/organization-switcher.mdx
---
{{ style: { maxWidth: '436px' } }}
The `` component allows a user to switch between their joined Organizations. If [Personal Accounts are enabled](/docs/guides/organizations/overview#allow-personal-accounts), users can also switch to their Personal Account. This component is useful for applications that have a multi-tenant architecture, where users can be part of multiple Organizations. It handles all Organization-related flows, including full Organization management for admins. Learn more about [Organizations](/docs/guides/organizations/overview).
## Example
```tsx {{ filename: 'app/routes/organization-switcher.tsx' }}
import { OrganizationSwitcher } from '@clerk/remix'
export default function OrganizationSwitcherPage() {
return
}
```
## Properties
The `` component accepts the following properties, all of which are **optional**:
* `afterCreateOrganizationUrl`
* `string`
The full URL or path to navigate to after creating a new Organization.
***
* `afterLeaveOrganizationUrl`
* `string`
The full URL or path to navigate to after the user leaves the currently Active OrganizationA user can be a member of multiple Organizations, but only one can be active at a time. The **Active Organization** determines which Organization-specific data the user can access and which Role and related Permissions they have within the Organization..
***
* `afterSelectOrganizationUrl`
* `string`
The full URL or path to navigate to after a successful Organization switch.
***
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `createOrganizationMode`
* `'modal' | 'navigation'`
A boolean that controls whether clicking the "Create organization" button will cause the \ component to open as a modal, or if the browser will navigate to the `createOrganizationUrl` where `` is mounted as a page. Defaults to: `'modal'`.
***
* `createOrganizationUrl`
* `string`
The full URL or path where the ``]createorg-ref component is mounted.
***
* `defaultOpen`
* `boolean`
A boolean that controls the default state of the `` component.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `hidePersonal`
* `boolean`
A boolean that controls whether `` will include the user's [Personal Account](/docs/guides/organizations/overview#allow-personal-accounts) in the Organization list. Setting this to `true` will hide the Personal Account option, and users will only be able to switch between Organizations. Defaults to `false`.
***
* `hideSlug`
* `boolean`
A boolean that controls whether the optional slug field in the Organization creation screen is hidden.
***
* `organizationProfileMode`
* `'modal' | 'navigation'`
A boolean that controls whether clicking the **Manage organization** button will cause the \ component to open as a modal, or if the browser will navigate to the `organizationProfileUrl` where `` is mounted as a page. Defaults to: `'modal'`.
***
* `organizationProfileProps`
* `object`
Specify options for the underlying \ component. For example: `{appearance: {...}}`
***
* `organizationProfileUrl`
* `string`
The full URL or path where the \ component is mounted.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
[createorg-ref]: /docs/reference/components/organization/create-organization
[orgprofile-ref]: /docs/reference/components/organization/organization-profile
---
title: "``"
description: The component is a button that links to the sign-in
page or displays the sign-in modal.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/unstyled/sign-in-button
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/unstyled/sign-in-button.mdx
---
The `` component is a button that, by default, links to your app's sign-in page. Your sign-in page will be hosted by Clerk using the [Account Portal](/docs/guides/customizing-clerk/account-portal) unless you have set up a dedicated sign-in page.
## Usage
### Basic usage
```tsx {{ filename: 'app/routes/_index.tsx' }}
import { SignInButton } from '@clerk/remix'
export default function Home() {
return
}
```
### Custom usage
You can create a custom button by wrapping your own button, or button text, in the `` component.
```tsx {{ filename: 'app/routes/_index.tsx' }}
import { SignInButton } from '@clerk/remix'
export default function Home() {
return (
Custom sign in button
)
}
```
## Properties
* `forceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs in. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `fallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `oauthFlow`
* `"redirect" | "popup" | "auto"`
Determines how OAuth authentication is performed. Accepts the following properties:
* `"redirect"`: Redirect to the OAuth provider on the current page.
* `"popup"`: Open a popup window.
* `"auto"`: Choose the best method based on whether the current domain typically requires the `"popup"` flow to correctly perform authentication.
Defaults to `"auto"`.
***
* `signUpForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs up. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpFallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `mode?`
* `'redirect' | 'modal'`
Determines what happens when a user clicks on the ``. Setting this to `'redirect'` will redirect the user to the sign-in route. Setting this to `'modal'` will open a modal on the current route. Defaults to `'redirect'`.
***
* `children?`
* `React.ReactNode`
Children you want to wrap the `` in.
***
* `initialValues`
* SignInInitialValues
The values used to prefill the sign-in fields with.
---
title: "``"
description: The `` component is used to complete a
one-click, cryptographically-secure sign-in flow using MetaMask.
sdk: expo, nextjs, nuxt, react, react-router, remix, tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/unstyled/sign-in-with-metamask
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,chrome-extension,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/unstyled/sign-in-with-metamask.mdx
---
The `` component is used to complete a one-click, cryptographically-secure sign-in flow using MetaMask.
## Usage
### Basic usage
```tsx {{ filename: 'app/routes/_index.tsx' }}
import { SignInWithMetamaskButton } from '@clerk/remix'
export default function Home() {
return
}
```
### Custom usage
In some cases, you will want to use your own button, or button text. You can do that by wrapping your button in the `` component.
```tsx {{ filename: 'app/routes/_index.tsx' }}
import { SignInWithMetamaskButton } from '@clerk/remix'
export default function Home() {
return (
Custom sign in button
)
}
```
---
title: "``"
description: The component is a button that links to the sign-up
page or displays the sign-up modal.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/unstyled/sign-up-button
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/unstyled/sign-up-button.mdx
---
The `` component is a button that, by default, links to your app's sign-up page. Your sign-up page will be hosted by Clerk using the [Account Portal](/docs/guides/customizing-clerk/account-portal) unless you have set up a dedicated sign-up page.
## Usage
### Basic usage
```jsx {{ filename: 'src/routes/_index.tsx' }}
import { SignUpButton } from '@clerk/remix'
export default function Home() {
return
}
```
### Custom usage
You can create a custom button by wrapping your own button, or button text, in the `` component.
```tsx {{ filename: 'app/routes/_index.tsx' }}
import { SignUpButton } from '@clerk/remix'
export default function Home() {
return (
Custom sign up button
)
}
```
## Properties
* `forceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs up. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `fallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `oauthFlow`
* `"redirect" | "popup" | "auto"`
Determines how OAuth authentication is performed. Accepts the following properties:
* `"redirect"`: Redirect to the OAuth provider on the current page.
* `"popup"`: Open a popup window.
* `"auto"`: Choose the best method based on whether the current domain typically requires the `"popup"` flow to correctly perform authentication.
Defaults to `"auto"`.
***
* `signInForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs in. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signInFallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `mode?`
* `'redirect' | 'modal'`
Determines what happens when a user clicks on the ``. Setting this to `'redirect'` will redirect the user to the sign-up route. Setting this to `'modal'` will open a modal on the current route. Defaults to `'redirect'`
***
* `children?`
* `React.ReactNode`
Children you want to wrap the `` in.
***
* `initialValues`
* SignUpInitialValues
The values used to prefill the sign-up fields with.
***
* `unsafeMetadata`
* SignUpUnsafeMetadata
Metadata that can be read and set from the frontend and the backend. Once the sign-up is complete, the value of this field will be automatically copied to the created user's unsafe metadata (`User.unsafeMetadata`). One common use case is to collect custom information about the user during the sign-up process and store it in this property. Read more about [unsafe metadata](/docs/guides/users/extending#unsafe-metadata).
---
title: "``"
description: The `` component is a button that signs a user out.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/unstyled/sign-out-button
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/unstyled/sign-out-button.mdx
---
The `` component is a button that signs a user out. By default, it is a `` tag that says **Sign Out**, but it is completely customizable by passing children.
## Usage
### Basic usage
```tsx {{ filename: 'app/routes/_index.tsx' }}
import { SignOutButton } from '@clerk/remix'
export default function Home() {
return
}
```
### Custom usage
You can create a custom button by wrapping your own button, or button text, in the `` component.
```tsx {{ filename: 'app/routes/_index.tsx' }}
import { SignOutButton } from '@clerk/remix'
export default function Home() {
return (
Custom sign out button
)
}
```
### Multi-session usage
#### Sign out of all sessions
Clicking the `` component signs the user out of all sessions. This is the default behavior.
#### Sign out of a specific session
You can sign out of a specific session by passing in a `sessionId` to the `sessionId` prop. This is useful for signing a single account out of a [multi-session application](/docs/guides/secure/session-options#multi-session-applications).
In the following example, the `sessionId` is retrieved from the useAuth() hook. If the user is not signed in, the `sessionId` will be `null`, and the user is shown the \ component. If the user is signed in, the user is shown the `` component, which when clicked, signs the user out of that specific session.
```tsx {{ filename: 'app/routes/_index.tsx' }}
import { SignInButton, SignOutButton, useAuth } from '@clerk/remix'
export default function Home() {
const { sessionId } = useAuth()
if (!sessionId) {
return
}
return
}
```
## Properties
* `redirectUrl?`
* `string`
The full URL or path to navigate after successful sign-out.
***
* `sessionId?`
* `string`
The ID of a specific session to sign out of. Useful for [multi-session applications](/docs/guides/secure/session-options#multi-session-applications).
***
* `children?`
* `React.ReactNode`
Children you want to wrap the `` in.
---
title: "`` component"
description: Clerk's component is used to render the familiar
user button UI popularized by Google.
search:
rank: 1
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/user/user-button
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/user/user-button.mdx
---
{{ style: { maxWidth: '436px' } }}
The `` component renders the familiar user button UI popularized by Google. When selected, it opens a dropdown menu with options to manage account settings and sign out. The "Manage account" option launches the \ component, providing access to profile and security settings.
For users that have [multi-session](/docs/guides/secure/session-options#multi-session-applications) enabled, the `` also allows users to sign into multiple accounts at once and instantly switch between them without the need for a full page reload. Learn more [here](/docs/guides/secure/session-options#multi-session-applications).
## Example
In the following example, `` is mounted inside a header component, which is a common pattern on many websites and applications. When the user is signed in, they will see their avatar and be able to open the popup menu.
```tsx {{ filename: 'app/routes/_index.tsx' }}
import { SignedIn, UserButton, SignInButton, SignedOut } from '@clerk/remix'
export default function Index() {
return (
)
}
```
## Properties
The `` component accepts the following properties, all of which are **optional**:
* `afterMultiSessionSingleSignOutUrl` (deprecated)
* `string`
**Deprecated. Move `afterMultiSessionSingleSignOutUrl` to \.** The full URL or path to navigate to after signing out from a currently active account in a multi-session app.
***
* `afterSignOutUrl` (deprecated)
* `string`
**Deprecated. Move `afterSignOutUrl` to \.** The full URL or path to navigate to after a successful sign-out.
***
* `afterSwitchSessionUrl`
* `string`
The full URL or path to navigate to after a successful account change in a multi-session app.
***
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `defaultOpen`
* `boolean`
Controls whether the `` should open by default during the first render.
***
* `showName`
* `boolean`
Controls if the user name is displayed next to the user image button.
***
* `signInUrl`
* `string`
The full URL or path to navigate to when the **Add another account** button is clicked. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `userProfileMode`
* `'modal' | 'navigation'`
Controls whether selecting the **Manage your account** button will cause the \ component to open as a modal, or if the browser will navigate to the `userProfileUrl` where `` is mounted as a page. Defaults to: `'modal'`.
***
* `userProfileProps`
* `object`
Specify options for the underlying \ component. For example: `{additionalOAuthScopes: {google: ['foo', 'bar'], github: ['qux']}}`.
***
* `userProfileUrl`
* `string`
The full URL or path leading to the user management interface.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
You can also [add custom actions and links to the `` menu](/docs/guides/customizing-clerk/adding-items/user-button).
---
title: "`` component"
description: Clerk's component is used to render a beautiful,
full-featured account management UI that allows users to manage their profile
and security settings.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/user/user-profile
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/user/user-profile.mdx
---
{{ style: { maxWidth: '100%' } }}
The `` component is used to render a beautiful, full-featured account management UI that allows users to manage their profile, security, and billing settings.
## Example
The `` component must be embedded using the [Remix optional route](https://reactrouter.com/en/main/route/route#optional-segments) in order for the routing to work.
```tsx {{ filename: 'app/routes/user.$.tsx' }}
import { UserProfile } from '@clerk/remix'
export default function UserProfilePage() {
return
}
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash-based routing. For example: `/user-profile`.
***
* `additionalOAuthScopes`
* `object`
Specify additional scopes per OAuth provider that your users would like to provide if not already approved. For example: `{google: ['foo', 'bar'], github: ['qux']}`.
***
* `customPages`
* CustomPage\[]
An array of custom pages to add to the user profile. Only available for the JavaScript SDK. To add custom pages with React-based SDK's, see the [dedicated guide](/docs/guides/customizing-clerk/adding-items/user-profile).
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
In addition, you also can add custom pages and links to the `` navigation sidenav. For more information, refer to the [Custom Pages documentation](/docs/guides/customizing-clerk/adding-items/user-profile).
---
title: "`` component"
description: Clerk's component is used to render the familiar
user avatar on its own.
search:
rank: 1
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/user/user-avatar
lastUpdated: 2025-11-21T23:29:30.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/components/user/user-avatar.mdx
---

The `` component renders the authenticated user's avatar on its own, a common UI element found across many websites and applications.
## Example
In the following example, `` is mounted inside a header component, which is a common pattern on many websites and applications. When the user is signed in, they will see their avatar.
```tsx {{ filename: 'app/routes/_index.tsx' }}
import { SignedIn, UserAvatar, SignInButton, SignedOut } from '@clerk/remix'
export default function Index() {
return (
)
}
```
## Properties
The `` component accepts the following properties, all of which are **optional**:
* `rounded?`
* `boolean`
Determines whether the user avatar is displayed with rounded corners.
***
* `appearance?`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback?`
* `ReactNode`
Optional element to be rendered while the component is mounting.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
---
title: Hooks Reference
description: A list of Clerk's comprehensive suite of hooks for managing
authentication, sessions, sign-in and sign-up flows, Organizations, and
reverification.
sdk: astro, chrome-extension, expo, nextjs, react, react-router, remix,
tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/overview
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,react,react-router,remix,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,nuxt,vue,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/hooks/overview.mdx
---
Clerk offers a comprehensive suite of hooks that expose low-level access to authentication, session management, and multi-tenancy. With Clerk hooks, you can access and manage user data, handle sign-in and sign-up flows, control session management, and implement advanced flows like session reverification for sensitive actions. By using these hooks, you can extend or replace Clerk's built-in components and customize how authentication behaves in your application.
## Hooks
* useUser()
* useClerk()
* useAuth()
* useSignIn()
* useSignUp()
* useSession()
* useSessionList()
* useOrganization()
* useOrganizationList()
* useReverification()
* useCheckout()
* usePaymentElement()
* usePaymentMethods()
* usePlans()
* useSubscription()
* useStatements()
* usePaymentAttempts()
* [Join our Discord](https://clerk.com/discord "Join Discord")
* Join our official Discord server to chat with us directly and become a part of the Clerk community.
* {}
***
* [Need help?](/support "Get help")
* Contact us through Discord, Twitter, or email to receive answers to your questions and learn more about Clerk.
* {}
---
title: "`useOrganizationList()`"
description: Access and manage the current user's Organization list in your
React application with Clerk's useOrganizationList() hook.
sdk: chrome-extension, expo, nextjs, react, react-router, remix,
tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-organization-list
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: chrome-extension,expo,nextjs,react,react-router,remix,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/hooks/use-organization-list.mdx
---
The `useOrganizationList()` hook provides access to the current user's Organization memberships, invitations, and suggestions. It also includes methods for creating new Organizations and managing the Active OrganizationA user can be a member of multiple Organizations, but only one can be active at a time. The **Active Organization** determines which Organization-specific data the user can access and which Role and related Permissions they have within the Organization..
## Parameters
`useOrganizationList()` accepts a single object with the following properties:
| Property | Type | Description |
| ----------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `userInvitations?` | true \| \{ initialPage?: number; pageSize?: number; \} & \{ status?: "expired" \| "pending" \| "accepted" \| "revoked"; \} & \{ infinite?: boolean; keepPreviousData?: boolean; \} | If set to `true`, all default properties will be used. Otherwise, accepts an object with the following optional properties:
`status`: A string that filters the invitations by the provided status.
Any of the properties described in Shared properties.
|
| `userMemberships?` | true \| \{ initialPage?: number; pageSize?: number; \} & object & \{ infinite?: boolean; keepPreviousData?: boolean; \} | If set to `true`, all default properties will be used. Otherwise, accepts an object with the following optional properties:
Any of the properties described in Shared properties.
|
| `userSuggestions?` | true \| \{ initialPage?: number; pageSize?: number; \} & \{ status?: "pending" \| "accepted" \| ("pending" \| "accepted")\[]; \} & \{ infinite?: boolean; keepPreviousData?: boolean; \} | If set to `true`, all default properties will be used. Otherwise, accepts an object with the following optional properties:
`status`: A string that filters the suggestions by the provided status.
Any of the properties described in Shared properties.
|
> \[!WARNING]
> By default, the `userMemberships`, `userInvitations`, and `userSuggestions` attributes are not populated. To fetch and paginate the data, you must pass `true` or an object with the desired properties.
### Shared properties
Optional properties that are shared across the `userMemberships`, `userInvitations`, and `userSuggestions` properties.
| Property | Type | Description |
| --------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `initialPage?` | `number` | A number that specifies which page to fetch. For example, if `initialPage` is set to 10, it will skip the first 9 pages and fetch the 10th page. Defaults to `1`. |
| `pageSize?` | `number` | A number that specifies the maximum number of results to return per page. Defaults to `10`. |
| Name | Type | Description |
| ------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `infinite?` | `boolean` | If `true`, newly fetched data will be appended to the existing list rather than replacing it. Useful for implementing infinite scroll functionality. Defaults to `false`. |
| `keepPreviousData?` | `boolean` | If `true`, the previous data will be kept in the cache until new data is fetched. Defaults to `false`. |
## Returns
| Property | Type | Description |
| ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `createOrganization` | undefined \| (CreateOrganizationParams: CreateOrganizationParams) => Promise\<OrganizationResource\> | A function that returns a `Promise` which resolves to the newly created `Organization`. |
| `isLoaded` | `boolean` | A boolean that indicates whether Clerk has completed initialization and there is an authenticated user. Initially `false`, becomes `true` once Clerk loads with a user. |
| `setActive` | undefined \| (setActiveParams: SetActiveParams) => Promise\ | A function that sets the active session and/or organization. |
| `userInvitations` | PaginatedResourcesWithDefault\<UserOrganizationInvitationResource\> \| PaginatedResources\<UserOrganizationInvitationResource, T\["userInvitations"] *extends* \{ infinite: true; \} ? true : false\> | Returns `PaginatedResources` which includes a list of the user's organization invitations. |
| `userMemberships` | PaginatedResourcesWithDefault\<OrganizationMembershipResource\> \| PaginatedResources\<OrganizationMembershipResource, T\["userMemberships"] *extends* \{ infinite: true; \} ? true : false\> | Returns `PaginatedResources` which includes a list of the user's organization memberships. |
| `userSuggestions` | PaginatedResourcesWithDefault\<OrganizationSuggestionResource\> \| PaginatedResources\<OrganizationSuggestionResource, T\["userSuggestions"] *extends* \{ infinite: true; \} ? true : false\> | Returns `PaginatedResources` which includes a list of suggestions for organizations that the user can join. |
### `CreateOrganizationParams`
| Property | Type | Description |
| ------------------------- | -------- | ----------------------------- |
| `name` | `string` | The name of the organization. |
| `slug?` | `string` | The slug of the organization. |
### `PaginatedResources`
| Property | Type | Description |
| ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `count` | `number` | The total count of data that exist remotely. |
| `data` | T\[] | An array that contains the fetched data. For example, for the `memberships` attribute, data will be an array of OrganizationMembership objects. |
| `error` | null \| ClerkAPIResponseError | Clerk's API response error object. |
| `fetchNext` | () => void | A function that triggers the next page to be loaded. This is the same as `fetchPage(page => Math.min(pageCount, page + 1))`. |
| `fetchPage` | `ValueOrSetter`\<`number`\> | A function that triggers a specific page to be loaded. |
| `fetchPrevious` | () => void | A function that triggers the previous page to be loaded. This is the same as `fetchPage(page => Math.max(0, page - 1))`. |
| `hasNextPage` | `boolean` | A boolean that indicates if there are available pages to be fetched. |
| `hasPreviousPage` | `boolean` | A boolean that indicates if there are available pages to be fetched. |
| `isError` | `boolean` | A boolean that indicates the request failed. |
| `isFetching` | `boolean` | A boolean that is `true` if there is an ongoing request or a revalidation. |
| `isLoading` | `boolean` | A boolean that is `true` if there is an ongoing request and there is no fetched data. |
| `page` | `number` | The current page. |
| `pageCount` | `number` | The total amount of pages. It is calculated based on `count`, `initialPage`, and `pageSize`. |
| `revalidate` | () => Promise\ | A function that triggers a revalidation of the current page. |
| `setData` | `Infinite` *extends* `true` ? `CacheSetter`\<(undefined \| ClerkPaginatedResponse\)\[]\> : `CacheSetter`\<undefined \| ClerkPaginatedResponse\\> | A function that allows you to set the data manually. |
To see the different Organization features integrated into one application, take a look at our [Organizations demo repository](https://github.com/clerk/organizations-demo).
## Examples
### Expanding and paginating attributes
To keep network usage to a minimum, developers are required to opt-in by specifying which resource they need to fetch and paginate through. So by default, the `userMemberships`, `userInvitations`, and `userSuggestions` attributes are not populated. You must pass `true` or an object with the desired properties to fetch and paginate the data.
```jsx
// userMemberships.data will never be populated
const { userMemberships } = useOrganizationList()
// Use default values to fetch userMemberships, such as initialPage = 1 and pageSize = 10
const { userMemberships } = useOrganizationList({
userMemberships: true,
})
// Pass your own values to fetch userMemberships
const { userMemberships } = useOrganizationList({
userMemberships: {
pageSize: 20,
initialPage: 2, // skips the first page
},
})
// Aggregate pages in order to render an infinite list
const { userMemberships } = useOrganizationList({
userMemberships: {
infinite: true,
},
})
```
### Infinite pagination
The following example demonstrates how to use the `infinite` property to fetch and append new data to the existing list. The `userMemberships` attribute will be populated with the first page of the user's Organization memberships. When the "Load more" button is clicked, the `fetchNext` helper function will be called to append the next page of memberships to the list.
### Simple pagination
The following example demonstrates how to use the `fetchPrevious` and `fetchNext` helper functions to paginate through the data. The `userInvitations` attribute will be populated with the first page of invitations. When the "Previous page" or "Next page" button is clicked, the `fetchPrevious` or `fetchNext` helper function will be called to fetch the previous or next page of invitations.
Notice the difference between this example's pagination and the infinite pagination example above.
## Related guides
* [Build a custom Organization switcher](/docs/guides/development/custom-flows/organizations/organization-switcher)
* Use Clerk's API to build a custom flow for switching between Organizations
***
* [Create Organizations](/docs/guides/development/custom-flows/organizations/create-organizations)
* Use Clerk's API to build a custom flow for creating Organizations
***
* [Manage a user's Organization invitations](/docs/guides/development/custom-flows/organizations/manage-user-org-invitations)
* Use Clerk's API to build a custom flow for managing user's Organization invitations
---
title: useOrganization()
description: Access and manage the currently active Organization in your React
application with Clerk's useOrganization() hook.
search:
rank: 1
sdk: chrome-extension, expo, nextjs, react, react-router, remix,
tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-organization
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: chrome-extension,expo,nextjs,react,react-router,remix,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/hooks/use-organization.mdx
---
The `useOrganization()` hook retrieves attributes of the currently Active OrganizationA user can be a member of multiple Organizations, but only one can be active at a time. The **Active Organization** determines which Organization-specific data the user can access and which Role and related Permissions they have within the Organization..
## Parameters
`useOrganization()` accepts a single object with the following optional properties:
| Property | Type | Description |
| ----------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `domains?` | true \| \{ initialPage?: number; pageSize?: number; \} & \{ enrollmentMode?: "manual\_invitation" \| "automatic\_invitation" \| "automatic\_suggestion"; \} & \{ infinite?: boolean; keepPreviousData?: boolean; \} | If set to `true`, all default properties will be used. Otherwise, accepts an object with the following optional properties:
`enrollmentMode`: A string that filters the domains by the provided [enrollment mode](/docs/guides/organizations/verified-domains#enrollment-mode).
Any of the properties described in Shared properties.
|
| `invitations?` | true \| \{ initialPage?: number; pageSize?: number; \} & \{ status?: ("expired" \| "pending" \| "accepted" \| "revoked")\[]; \} & \{ infinite?: boolean; keepPreviousData?: boolean; \} | If set to `true`, all default properties will be used. Otherwise, accepts an object with the following optional properties:
`status`: A string that filters the invitations by the provided status.
Any of the properties described in Shared properties.
|
| `membershipRequests?` | true \| \{ initialPage?: number; pageSize?: number; \} & \{ status?: "expired" \| "pending" \| "accepted" \| "revoked"; \} & \{ infinite?: boolean; keepPreviousData?: boolean; \} | If set to `true`, all default properties will be used. Otherwise, accepts an object with the following optional properties:
`status`: A string that filters the membership requests by the provided status.
Any of the properties described in Shared properties.
|
| `memberships?` | true \| \{ initialPage?: number; pageSize?: number; \} & \{ query?: string; role?: string\[]; \} & \{ infinite?: boolean; keepPreviousData?: boolean; \} | If set to `true`, all default properties will be used. Otherwise, accepts an object with the following optional properties:
`role`: An array of OrganizationCustomRoleKey.
`query`: A string that filters the memberships by the provided string.
Any of the properties described in Shared properties.
|
> \[!WARNING]
> By default, the `memberships`, `invitations`, `membershipRequests`, and `domains` attributes aren't populated. To fetch and paginate the data, you must pass `true` or an object with the desired properties.
### Shared properties
Optional properties that are shared across the `invitations`, `membershipRequests`, `memberships`, and `domains` properties.
| Property | Type | Description |
| --------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `initialPage?` | `number` | A number that specifies which page to fetch. For example, if `initialPage` is set to 10, it will skip the first 9 pages and fetch the 10th page. Defaults to `1`. |
| `pageSize?` | `number` | A number that specifies the maximum number of results to return per page. Defaults to `10`. |
| Name | Type | Description |
| ------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `infinite?` | `boolean` | If `true`, newly fetched data will be appended to the existing list rather than replacing it. Useful for implementing infinite scroll functionality. Defaults to `false`. |
| `keepPreviousData?` | `boolean` | If `true`, the previous data will be kept in the cache until new data is fetched. Defaults to `false`. |
> \[!NOTE]
> These attributes are updating automatically and will re-render their respective components whenever you set a different Organization using the setActive(\{ organization }) method or update any of the memberships or invitations. No need for you to manage updating anything manually.
## Returns
| Property | Type | Description |
| ---------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `domains` | null \| PaginatedResourcesWithDefault\<OrganizationDomainResource\> \| PaginatedResources\<OrganizationDomainResource, T\["membershipRequests"] *extends* \{ infinite: true; \} ? true : false\> | Includes a paginated list of the organization's domains. |
| `invitations` | null \| PaginatedResourcesWithDefault\<OrganizationInvitationResource\> \| PaginatedResources\<OrganizationInvitationResource, T\["invitations"] *extends* \{ infinite: true; \} ? true : false\> | Includes a paginated list of the organization's invitations. |
| `isLoaded` | `boolean` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `membership` | undefined \| null \| OrganizationMembershipResource | The current organization membership. |
| `membershipRequests` | null \| PaginatedResourcesWithDefault\<OrganizationMembershipRequestResource\> \| PaginatedResources\<OrganizationMembershipRequestResource, T\["membershipRequests"] *extends* \{ infinite: true; \} ? true : false\> | Includes a paginated list of the organization's membership requests. |
| `memberships` | null \| PaginatedResourcesWithDefault\<OrganizationMembershipResource\> \| PaginatedResources\<OrganizationMembershipResource, T\["memberships"] *extends* \{ infinite: true; \} ? true : false\> | Includes a paginated list of the organization's memberships. |
| `organization` | undefined \| null \| OrganizationResource | The currently active organization. |
### `PaginatedResources`
| Property | Type | Description |
| ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `count` | `number` | The total count of data that exist remotely. |
| `data` | T\[] | An array that contains the fetched data. For example, for the `memberships` attribute, data will be an array of OrganizationMembership objects. |
| `error` | null \| ClerkAPIResponseError | Clerk's API response error object. |
| `fetchNext` | () => void | A function that triggers the next page to be loaded. This is the same as `fetchPage(page => Math.min(pageCount, page + 1))`. |
| `fetchPage` | `ValueOrSetter`\<`number`\> | A function that triggers a specific page to be loaded. |
| `fetchPrevious` | () => void | A function that triggers the previous page to be loaded. This is the same as `fetchPage(page => Math.max(0, page - 1))`. |
| `hasNextPage` | `boolean` | A boolean that indicates if there are available pages to be fetched. |
| `hasPreviousPage` | `boolean` | A boolean that indicates if there are available pages to be fetched. |
| `isError` | `boolean` | A boolean that indicates the request failed. |
| `isFetching` | `boolean` | A boolean that is `true` if there is an ongoing request or a revalidation. |
| `isLoading` | `boolean` | A boolean that is `true` if there is an ongoing request and there is no fetched data. |
| `page` | `number` | The current page. |
| `pageCount` | `number` | The total amount of pages. It is calculated based on `count`, `initialPage`, and `pageSize`. |
| `revalidate` | () => Promise\ | A function that triggers a revalidation of the current page. |
| `setData` | `Infinite` *extends* `true` ? `CacheSetter`\<(undefined \| ClerkPaginatedResponse\)\[]\> : `CacheSetter`\<undefined \| ClerkPaginatedResponse\\> | A function that allows you to set the data manually. |
To see the different Organization features integrated into one application, take a look at our [Organizations demo repository](https://github.com/clerk/organizations-demo).
## Examples
### Expand and paginate attributes
To keep network usage to a minimum, developers are required to opt-in by specifying which resource they need to fetch and paginate through. By default, the `memberships`, `invitations`, `membershipRequests`, and `domains` attributes are not populated. You must pass `true` or an object with the desired properties to fetch and paginate the data.
```jsx
// invitations.data will never be populated.
const { invitations } = useOrganization()
// Use default values to fetch invitations, such as initialPage = 1 and pageSize = 10
const { invitations } = useOrganization({
invitations: true,
})
// Pass your own values to fetch invitations
const { invitations } = useOrganization({
invitations: {
pageSize: 20,
initialPage: 2, // skips the first page
},
})
// Aggregate pages in order to render an infinite list
const { invitations } = useOrganization({
invitations: {
infinite: true,
},
})
```
### Infinite pagination
The following example demonstrates how to use the `infinite` property to fetch and append new data to the existing list. The `memberships` attribute will be populated with the first page of the Organization's memberships. When the "Load more" button is clicked, the `fetchNext` helper function will be called to append the next page of memberships to the list.
### Simple pagination
The following example demonstrates how to use the `fetchPrevious` and `fetchNext` helper functions to paginate through the data. The `memberships` attribute will be populated with the first page of the Organization's memberships. When the "Previous page" or "Next page" button is clicked, the `fetchPrevious` or `fetchNext` helper function will be called to fetch the previous or next page of memberships.
Notice the difference between this example's pagination and the infinite pagination example above.
## Related guides
* [Update an Organization](/docs/guides/development/custom-flows/organizations/update-organizations)
* Use Clerk's API to build a custom flow for updating an Organization
***
* [Manage Roles in an Organization](/docs/guides/development/custom-flows/organizations/manage-roles)
* Use Clerk's API to build a custom flow for managing Roles in an Organization
***
* [Manage an Organization's membership requests](/docs/guides/development/custom-flows/organizations/manage-membership-requests)
* Use Clerk's API to build a custom flow for managing an Organization's membership requests
***
* [Manage a user's Organization invitations](/docs/guides/development/custom-flows/organizations/manage-user-org-invitations)
* Use Clerk's API to build a custom flow for managing user's Organization invitations
---
title: useReverification()
description: Clerk's useReverification() hook enhances a fetcher function to
handle a session's reverification flow.
sdk: chrome-extension, expo, nextjs, react, react-router, remix,
tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-reverification
lastUpdated: 2025-11-21T22:25:46.000Z
availableSdks: chrome-extension,expo,nextjs,react,react-router,remix,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: remix
sourceFile: /docs/reference/hooks/use-reverification.mdx
---
> \[!WARNING]
>
> Depending on the SDK you're using, this feature requires `@clerk/nextjs@6.12.7` or later, `@clerk/clerk-react@5.25.1` or later, `@clerk/clerk-js@5.57.1` or later and `@clerk/clerk-sdk-ruby@3.3.0` or later.
Reverification allows you to prompt a user to verify their credentials before performing sensitive actions, even if they're already authenticated. For example, in a banking application, transferring money is considered a "sensitive action." Reverification can be used to confirm the user's identity.
The `useReverification()` hook is used to handle a session's reverification flow. If a request requires reverification, a modal will display, prompting the user to verify their credentials. Upon successful verification, the original request will automatically retry. If you'd like to build a custom UI, you can use the onNeedsReverification option.
When using reverification, a user's credentials are valid for 10 minutes. Once stale, a user will need to reverify their credentials. This time duration can be customized by using the `has()` helper on the server-side. See the [guide on reverification](/docs/guides/secure/reverification) for more information.
## Parameters
| Parameter | Type | Description |
| ---------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `fetcher` | `Fetcher extends (...args: any[]) => Promise` | A function that returns a promise. |
| `options?` | `Options` | Optional configuration object extending UseReverificationOptions. |
### `UseReverificationOptions`
The optional options object.
| Property | Type | Description |
| ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `onNeedsReverification?` | (properties: NeedsReverificationParameters) => void | Handler for the reverification process. Opts out of using the default UI. Use this to build a custom UI. |
### `NeedsReverificationParameters`
| Property | Type | Description |
| -------------------------------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| `cancel` | () => void | Marks the reverification process as cancelled and rejects the original request. |
| `complete` | () => void | Marks the reverification process as complete and retries the original request. |
| `level` | undefined \| "first\_factor" \| "second\_factor" \| "multi\_factor" | The verification level required for the reverification process. |
## Examples
The `useReverification()` hook displays a prebuilt UI when the user needs to reverify their credentials. You can also build a custom UI to handle the reverification process yourself. Use the following tabs to see examples of either option.
### Handle reverification for an action
The following example demonstrates how to use the `useReverification()` hook to require a user to reverify their credentials before being able to update their primary email address. It also demonstrates how to handle the cancellation of the reverification process.
### Handle reverification for a fetcher function
The following example demonstrates how to use the `useReverification()` hook to enhance a fetcher function that fetches data from a route that requires reverification. For examples on how to set up a route that requires reverification, see the [guide on reverification](/docs/guides/secure/reverification).
```tsx {{ filename: 'components/AccountBalance.tsx' }}
import { useReverification } from '@clerk/remix'
import { isClerkRuntimeError, isReverificationCancelledError } from '@clerk/shared'
import { useState } from 'react'
export function AccountBalance() {
const [balance, setBalance] = useState(null)
const accountBalance = useReverification(async () => {
const response = await fetch('/api/balance')
return await response.json()
})
const handleClick = async () => {
try {
const accountBalanceResponse = await accountBalance()
setBalance(accountBalanceResponse.amount)
} catch (e) {
// Handle if user cancels the reverification process
if (isClerkRuntimeError(e) && isReverificationCancelledError(e)) {
console.error('User cancelled reverification', e.code)
}
// Handle other errors
// See https://clerk.com/docs/custom-flows/error-handling
// for more info on error handling
console.error(JSON.stringify(e, null, 2))
}
}
return (
Your account balance is {balance ? `$${balance}` : '$******'} handleClick()}>See account balance
)
}
```
The following example demonstrates how to build a custom UI when using the `useReverification()` hook. In the example, the `useReverification()` hook is used to require a user to reverify their credentials before being able to update their primary email address. It requires two components: the `` component displays the list of email addresses to choose from and it renders the second component, ``, which handles the reverification process.
The example handles first factor verification using an email code, so you will need to have the [**Email verification code**](/docs/guides/configure/auth-strategies/sign-up-sign-in-options#email) setting enabled for your application. But you can adapt this example to handle any type of verification level or strategy.
The `` component uses `useReverification()` to enhance the `update()` method, requiring the user to reverify their credentials before being able to update their primary email address.
The `useReverification()` hook provides the `onNeedsReverification` option, which is a handler for building a custom UI. It provides four properties: `level`, `complete`, `cancel`, and `inProgress`. The example tracks these using the `verificationState` state variable.
* The `level` property determines the verification level required for the reverification process. This example only handles first factor verification, which is done in the `` component.
* The `complete` and `cancel` properties are the steps of the reverification process, which is also done in the `` component.
* The `inProgress` property is used to track the state of the reverification process. When the user selects the "Make primary" button, it triggers the reverification process and sets the `inProgress` property is `true`, which displays the `` component.
```tsx {{ filename: 'components/UpdateUserEmail.tsx', collapsible: true }}
import { useReverification, useUser } from '@clerk/remix'
import { isClerkRuntimeError, isReverificationCancelledError } from '@clerk/shared'
import { useState } from 'react'
import { SessionVerificationLevel } from '@clerk/types'
import { VerificationComponent } from './VerificationComponent'
export function UpdateUserEmail() {
// Use `useUser()` to get the current user's `User` object
// `User` includes the `update()` method to update the user's primary email address
const { user } = useUser()
// TODO: Update to use exported type once available
const [verificationState, setVerificationState] = useState<
| {
complete: () => void
cancel: () => void
level: SessionVerificationLevel | undefined
inProgress: boolean
}
| undefined
>(undefined)
// Use `useReverification()` to enhance the `update()` method
// to handle the reverification process
const changePrimaryEmail = useReverification(
(emailAddressId: string) => user?.update({ primaryEmailAddressId: emailAddressId }),
{
onNeedsReverification: ({ complete, cancel, level }) => {
setVerificationState({
complete,
cancel,
level,
inProgress: true,
})
},
},
)
const handleClick = async (emailAddressId: string) => {
try {
await changePrimaryEmail(emailAddressId)
} catch (e) {
// Handle if user cancels the reverification process
if (isClerkRuntimeError(e) && isReverificationCancelledError(e)) {
console.error('User cancelled reverification', e.code)
}
// Handle other errors
// See https://clerk.com/docs/custom-flows/error-handling
// for more info on error handling
console.error(JSON.stringify(e, null, 2))
}
}
return (
Your primary email address is {user?.primaryEmailAddress?.emailAddress}
)
}
```
The `` component handles the reverification process. It uses the `level` property to determine the verification level, which is set to `first_factor`. First, it finds the determined starting first factor from the supported first factors. Then, it prepares the first factor verification using the `strategy` (`email_code` in this case) and `emailAddressId` properties. Finally, it attempts to verify the session with email code provided by the user. If the verification is successful, the `onComplete()` handler is called to complete the reverification process.
```tsx {{ filename: 'components/VerificationComponent.tsx', collapsible: true }}
import { useEffect, useRef, useState } from 'react'
import { useSession } from '@clerk/remix'
import {
EmailCodeFactor,
SessionVerificationLevel,
SessionVerificationResource,
} from '@clerk/types'
export function VerificationComponent({
level = 'first_factor',
onComplete,
onCancel,
}: {
level: SessionVerificationLevel | undefined
onComplete: () => void
onCancel: () => void
}) {
const { session } = useSession()
const [code, setCode] = useState('')
const reverificationRef = useRef(undefined)
const [determinedStartingFirstFactor, setDeterminedStartingFirstFactor] = useState<
EmailCodeFactor | undefined
>()
useEffect(() => {
if (reverificationRef.current) {
return
}
session?.startVerification({ level }).then(async (response) => {
reverificationRef.current = response
await prepareEmailVerification(response)
})
}, [])
const prepareEmailVerification = async (verificationResource: SessionVerificationResource) => {
// To simplify the example we will only handle the first factor verification
if (verificationResource.status === 'needs_first_factor') {
// Determine the starting first factor from the supported first factors
const determinedStartingFirstFactor = verificationResource.supportedFirstFactors?.filter(
(factor) => factor.strategy === 'email_code',
)[0]
if (determinedStartingFirstFactor) {
setDeterminedStartingFirstFactor(determinedStartingFirstFactor)
// Prepare the first factor verification with the determined starting first factor
await session?.prepareFirstFactorVerification({
strategy: determinedStartingFirstFactor.strategy,
emailAddressId: determinedStartingFirstFactor?.emailAddressId,
})
}
}
}
const handleVerificationAttempt = async () => {
try {
// Attempt to verify the session with the provided code
await session?.attemptFirstFactorVerification({
strategy: 'email_code',
code,
})
onComplete()
} catch (e) {
// Any error from the attempt to verify the session can be handled here
console.error('Error verifying session', e)
}
}
if (!determinedStartingFirstFactor) {
return null
}
return (
Enter verification code sent to {determinedStartingFirstFactor.safeIdentifier || ''}
)
}
```
## Related guides
See the custom flowA **custom flow** refers to a user interface built entirely from scratch using the Clerk API. Learn more about [custom flows](/docs/guides/development/custom-flows/overview). guides for examples of how to use the `useReverification()` hook, such as the [Add a phone number to a user's account](/docs/guides/development/custom-flows/account-updates/add-phone) guide.
---
title: React Router Quickstart
description: Learn how to use Clerk to quickly and easily add secure
authentication and user management to your React Router application.
sdk: nextjs, react, js-frontend, chrome-extension, expo, android, ios,
expressjs, fastify, react-router, remix, tanstack-react-start, go, astro,
nuxt, vue, ruby, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/getting-started/quickstart
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,react,js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
notAvailableSdks: ""
activeSdk: react-router
sourceFile: /docs/getting-started/quickstart.react-router.mdx
---
React Router can be used in different modes: **declarative**, **data**, or **framework**. This tutorial explains how to use React Router in **framework** mode. To use React Router in **declarative** mode instead, see the [dedicated guide](/docs/guides/development/declarative-mode).
This tutorial assumes that you're using React Router **v7.1.2 or later** in framework mode.
## Install `@clerk/react-router`
The [Clerk React Router SDK](/docs/reference/react-router/overview) provides prebuilt components, hooks, and helpers to make it easy to integrate authentication and user management in your React Router app.
Run the following command to install the SDK:
```npm
npm install @clerk/react-router
```
## Set your Clerk API keys
Add the following keys to your `.env` file. These keys can always be retrieved from the [**API keys**](https://dashboard.clerk.com/~/api-keys) page in the Clerk Dashboard.
1. In the Clerk Dashboard, navigate to the [**API keys**](https://dashboard.clerk.com/~/api-keys) page.
2. In the **Quick Copy** section, copy your Clerk Publishable and Secret Key.
3. Paste your keys into your `.env` file.
The final result should resemble the following:
```env {{ filename: '.env' }}
VITE_CLERK_PUBLISHABLE_KEY={{pub_key}}
CLERK_SECRET_KEY={{secret}}
```
## Add `clerkMiddleware()` and `rootAuthLoader()` to your app
`clerkMiddleware()` grants you access to user authentication state throughout your app.
React Router middleware requires opting in via a future flag. Add the following to your `react-router.config.ts` file:
```ts {{ filename: 'react-router.config.ts' }}
import type { Config } from '@react-router/dev/config'
export default {
// ...
future: {
v8_middleware: true,
},
} satisfies Config
```
Then, add the following code to your `root.tsx` file to configure the `clerkMiddleware()` and `rootAuthLoader()` functions.
To load additional data or configure options, see the [`clerkMiddleware()`](/docs/reference/react-router/clerk-middleware) reference.
```tsx {{ filename: 'app/root.tsx', mark: [4, [6, 8]], fold: [[1, 3], [10, 71]], collapsible: true }}
import { isRouteErrorResponse, Links, Meta, Outlet, Scripts, ScrollRestoration } from 'react-router'
import type { Route } from './+types/root'
import stylesheet from './app.css?url'
import { clerkMiddleware, rootAuthLoader } from '@clerk/react-router/server'
export const middleware: Route.MiddlewareFunction[] = [clerkMiddleware()]
export const loader = (args: Route.LoaderArgs) => rootAuthLoader(args)
export const links: Route.LinksFunction = () => [
{ rel: 'preconnect', href: 'https://fonts.googleapis.com' },
{
rel: 'preconnect',
href: 'https://fonts.gstatic.com',
crossOrigin: 'anonymous',
},
{
rel: 'stylesheet',
href: 'https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap',
},
{ rel: 'stylesheet', href: stylesheet },
]
export function Layout({ children }: { children: React.ReactNode }) {
return (
{children}
)
}
export default function App() {
return
}
export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
let message = 'Oops!'
let details = 'An unexpected error occurred.'
let stack: string | undefined
if (isRouteErrorResponse(error)) {
message = error.status === 404 ? '404' : 'Error'
details =
error.status === 404 ? 'The requested page could not be found.' : error.statusText || details
} else if (import.meta.env.DEV && error && error instanceof Error) {
details = error.message
stack = error.stack
}
return (
{message}
{details}
{stack && (
{stack}
)}
)
}
```
## Add `` and Clerk components to your app
The \ component provides session and user context to Clerk's hooks and components. It's recommended to wrap your entire app at the entry point with `` to make authentication globally accessible. See the reference docs for other configuration options.
It's required to pass `loaderData` to the `` component. This data is provided by the `rootAuthLoader()` function.
The following example adds `` and creates a header using the following Clerk components:
* \: Children of this component can only be seen while **signed in**.
* \: Children of this component can only be seen while **signed out**.
* \: Shows the signed-in user's avatar. Selecting it opens a dropdown menu with account management options.
* \: An unstyled component that links to the sign-in page. In this example, since no props or [environment variables](/docs/guides/development/clerk-environment-variables) are set for the sign-in URL, this component links to the [Account Portal sign-in page](/docs/guides/customizing-clerk/account-portal#sign-in).
```tsx {{ filename: 'app/root.tsx', mark: [44, [46, 58], 60], fold: [[2, 42], [62, 87]] }}
import { ClerkProvider, SignedIn, SignedOut, UserButton, SignInButton } from '@clerk/react-router'
import { isRouteErrorResponse, Links, Meta, Outlet, Scripts, ScrollRestoration } from 'react-router'
import { clerkMiddleware, rootAuthLoader } from '@clerk/react-router/server'
import type { Route } from './+types/root'
import stylesheet from './app.css?url'
export const middleware: Route.MiddlewareFunction[] = [clerkMiddleware()]
export const loader = (args: Route.LoaderArgs) => rootAuthLoader(args)
export const links: Route.LinksFunction = () => [
{ rel: 'preconnect', href: 'https://fonts.googleapis.com' },
{
rel: 'preconnect',
href: 'https://fonts.gstatic.com',
crossOrigin: 'anonymous',
},
{
rel: 'stylesheet',
href: 'https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap',
},
{ rel: 'stylesheet', href: stylesheet },
]
export function Layout({ children }: { children: React.ReactNode }) {
return (
{children}
)
}
// Pull in the `loaderData` from the `rootAuthLoader()` function
export default function App({ loaderData }: Route.ComponentProps) {
return (
// Pass the `loaderData` to the `` component
{/* Show the sign-in button when the user is signed out */}
{/* Show the user button when the user is signed in */}
)
}
export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
let message = 'Oops!'
let details = 'An unexpected error occurred.'
let stack: string | undefined
if (isRouteErrorResponse(error)) {
message = error.status === 404 ? '404' : 'Error'
details =
error.status === 404 ? 'The requested page could not be found.' : error.statusText || details
} else if (import.meta.env.DEV && error && error instanceof Error) {
details = error.message
stack = error.stack
}
return (
{message}
{details}
{stack && (
{stack}
)}
)
}
```
## Create your first user
Run your project with the following command:
```npm
npm run dev
```
Visit your app's homepage at [`http://localhost:5173`](http://localhost:5173). Sign up to create your first user.
## Next steps
* [Create a custom sign-in-or-up page](/docs/react-router/guides/development/custom-sign-in-or-up-page)
* Learn how add custom sign-in-or-up page with Clerk components.
***
* [Protect content and read user data](/docs/react-router/guides/users/reading)
* Learn how to use Clerk's hooks and helpers to protect content and read user data in your React Router app.
***
* [Declarative mode](/docs/guides/development/declarative-mode)
* Learn how to use Clerk with React Router in declarative mode to add authentication to your application.
---
title: Clerk Billing for B2C SaaS
description: Clerk Billing is a feature that allows you to create and manage
Plans and Features for your application.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/billing/for-b2c
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: react-router
sourceFile: /docs/guides/billing/for-b2c.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing for B2C SaaS allows you to create Plans and manage Subscriptions **for individual users** in your application. If you'd like to charge companies or organizations, see Billing for B2B SaaS. You can also combine both B2C and B2B Billing in the same application.
## Enable Billing
To enable Billing for your application, navigate to the [**Billing Settings**](https://dashboard.clerk.com/~/billing/settings) page in the Clerk Dashboard. This page will guide you through enabling Billing for your application.
Clerk Billing costs the same as using Stripe Billing directly, just 0.7% per transaction, plus transaction fees which are paid directly to Stripe. Clerk Billing is **not** the same as Stripe Billing. Plans and pricing are managed directly through the Clerk Dashboard and won't sync with your existing Stripe products or plans. Clerk uses Stripe **only** for payment processing, so you don't need to set up Stripe Billing.
### Payment gateway
Once you have enabled Billing, you will see the following **Payment gateway** options for collecting payments via Stripe:
* **Clerk development gateway**: A shared **test** Stripe account used for development instances. This allows developers to test and build Billing flows **in development** without needing to create and configure a Stripe account.
* **Stripe account**: Use your own Stripe account for production. **A Stripe account created for a development instance cannot be used for production**. You will need to create a separate Stripe account for your production environment.
## Create a Plan
Subscription Plans are what your users subscribe to. There is no limit to the number of Plans you can create.
To create a Plan, navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard. Here, you can create, edit, and delete Plans. To setup B2C Billing, select the **Plans for Users** tab and select **Add Plan**. When creating a Plan, you can also create Features for the Plan; see the next section for more information.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's a user Plan, it can appear in the `` component. When creating or editing a Plan, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Add Features to a Plan
[Features](/docs/guides/secure/features) make it easy to give entitlements to your Plans. You can add any number of Features to a Plan.
You can add a Feature to a Plan when you are creating a Plan. To add it after a Plan is created:
1. Navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard.
2. Select the Plan you'd like to add a Feature to.
3. In the **Features** section, select **Add Feature**.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's a user Plan, it can appear in the `` component. When adding a Feature to a Plan, it will also automatically appear in the corresponding Plan. When creating or editing a Feature, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Create a pricing page
You can create a pricing page by using the \ component. This component displays a table of Plans and Features that users can subscribe to. **It's recommended to create a dedicated page**, as shown in the following example.
```tsx {{ filename: 'app/routes/pricing.tsx' }}
import type { Route } from './+types/pricing'
import { PricingTable } from '@clerk/react-router'
export function meta({}: Route.MetaArgs) {
return [{ title: 'Pricing' }]
}
export default function PricingPage() {
return (
)
}
```
## Control access with Features and Plans
You can use Clerk's Features and Plans to gate access to the content. There are a few ways to do this, but the recommended approach is to either use the has() method or the \ component.
The `has()` method is available for any JavaScript framework, while `` is only available for React-based frameworks.
### Example: Using `has()`
Use the `has()` method to test if the user has access to a **Plan**:
```jsx
const hasPremiumAccess = has({ plan: 'gold' })
```
Or a **Feature**:
```jsx
const hasPremiumAccess = has({ feature: 'widgets' })
```
The has() method is a server-side helper that checks if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan) and returns a boolean value. `has()` is available on the auth object, which you will access differently depending on the framework you are using.
The following example demonstrates how to use `has()` to check if a user has a Plan.
```tsx {{ filename: 'app/routes/bronze-content.tsx' }}
import type { Route } from './+types/bronze-content'
import { useAuth } from '@clerk/react-router'
export function meta({}: Route.MetaArgs) {
return [{ title: 'Bronze Content' }]
}
export default function BronzeContentPage() {
const { has, isLoaded } = useAuth()
if (!isLoaded) return
Loading...
const hasBronzePlan = has({ plan: 'bronze' })
if (!hasBronzePlan) return
Only subscribers to the Bronze plan can access this content.
return
For Bronze subscribers only
}
```
The following example demonstrates how to use `has()` to check if a user has a Feature.
```tsx {{ filename: 'app/routes/premium-content.tsx' }}
import type { Route } from './+types/premium-content'
import { useAuth } from '@clerk/react-router'
export function meta({}: Route.MetaArgs) {
return [{ title: 'Page' }]
}
export default function PremiumContentPage() {
const { isLoaded, has } = useAuth()
if (!isLoaded) return
Loading...
const hasPremiumAccess = has({ feature: 'premium_access' })
if (!hasPremiumAccess)
return
Only subscribers with the Premium Access feature can access this content.
return
Our Exclusive Content
}
```
### Example: Using ``
The \ component protects content or even entire routes by checking if the user has been granted a specific type of access control (Role, Permission, Feature, or Plan). You can pass a `fallback` prop to `` that will be rendered if the user does not have the access control.
The following example demonstrates how to use `` to protect a page by checking if the user has a Plan.
```tsx {{ filename: 'app/routes/protected-content.tsx' }}
import type { Route } from './+types/protected-content'
import { Protect } from '@clerk/react-router'
export function meta({}: Route.MetaArgs) {
return [{ title: 'Protected Content' }]
}
export default function ProtectedContentPage() {
return (
Only subscribers to the Bronze plan can access this content.}
>
Exclusive Bronze Content
This content is only visible to Bronze subscribers.
)
}
```
The following example demonstrates how to use `` to protect a page by checking if the user has a Feature.
```tsx {{ filename: 'app/routes/protected-premium-content.tsx' }}
import type { Route } from './+types/protected-premium-content'
import { Protect } from '@clerk/react-router'
export function meta({}: Route.MetaArgs) {
return [{ title: 'Protected Premium Content' }]
}
export default function ProtectedPremiumContentPage() {
return (
Only subscribers with the Premium Access feature can access this content.}
>
Exclusive Premium Content
This content is only visible to users with Premium Access feature.
)
}
```
---
title: Clerk Billing for B2B SaaS
description: Clerk Billing is a feature that allows you to create and manage
Plans and Features for your application.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/billing/for-b2b
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: react-router
sourceFile: /docs/guides/billing/for-b2b.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing for B2B SaaS allows you to create Plans and manage Subscriptions **for companies or organizations** in your application. If you'd like to charge individual users, see Billing for B2C SaaS. You can also combine both B2C and B2B Billing in the same application.
## Enable Billing
To enable Billing for your application, navigate to the [**Billing Settings**](https://dashboard.clerk.com/~/billing/settings) page in the Clerk Dashboard. This page will guide you through enabling Billing for your application.
Clerk Billing costs the same as using Stripe Billing directly, just 0.7% per transaction, plus transaction fees which are paid directly to Stripe. Clerk Billing is **not** the same as Stripe Billing. Plans and pricing are managed directly through the Clerk Dashboard and won't sync with your existing Stripe products or plans. Clerk uses Stripe **only** for payment processing, so you don't need to set up Stripe Billing.
### Payment gateway
Once you have enabled Billing, you will see the following **Payment gateway** options for collecting payments via Stripe:
* **Clerk development gateway**: A shared **test** Stripe account used for development instances. This allows developers to test and build Billing flows **in development** without needing to create and configure a Stripe account.
* **Stripe account**: Use your own Stripe account for production. **A Stripe account created for a development instance cannot be used for production**. You will need to create a separate Stripe account for your production environment.
## Create a Plan
Subscription Plans are what your customers subscribe to. There is no limit to the number of Plans you can create. If your Clerk instance has existing [Custom Permissions](/docs/guides/organizations/roles-and-permissions), the corresponding Features from those Permissions will automatically be added to the free Plan for Orgs. This ensures that Organization members get the same set of Custom Permissions when Billing is enabled, because all Organizations start on the free Plan.
To create a Plan, navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard. Here, you can create, edit, and delete Plans. To setup B2B Billing, select the **Plans for Organizations** tab and select **Add Plan**. When creating a Plan, you can also create [Features](/docs/guides/secure/features) for the Plan; see the next section for more information.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's an Organization Plan, it can appear in the `` component. When creating or editing a Plan, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Add Features to a Plan
[Features](/docs/guides/secure/features) make it easy to give entitlements to your Plans. You can add any number of Features to a Plan.
You can add a Feature to a Plan when you are creating a Plan. To add it after a Plan is created:
1. Navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard.
2. Select the Plan you'd like to add a Feature to.
3. In the **Features** section, select **Add Feature**.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's an Organization Plan, it can appear in the `` component. When adding a Feature to a Plan, it will also automatically appear in the corresponding Plan. When creating or editing a Feature, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Create a pricing page
You can create a pricing page by using the \ component. This component displays a table of Plans and Features that customers can subscribe to. **It's recommended to create a dedicated page**, as shown in the following example.
```tsx {{ filename: 'app/routes/pricing.tsx' }}
import type { Route } from './+types/pricing'
import { PricingTable } from '@clerk/react-router'
export function meta({}: Route.MetaArgs) {
return [{ title: 'Pricing' }]
}
export default function PricingPage() {
return (
)
}
```
## Control access with Features, Plans, and Permissions
You can use Clerk's Features, Plans, and Permissions to gate access to content using authorization checksAuthorization checks are checks you perform in your code to determine the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions or access certain content. Learn more about [authorization checks](/docs/guides/secure/authorization-checks).. There are a few ways to do this, but the recommended approach is to either use the has() method or the \ component.
The `has()` method is available for any JavaScript-based framework, while `` is a component, and therefore, is only available for React-based frameworks.
> \[!IMPORTANT]
> Permission-based authorization checks link with Feature-based authorization checks. This means that if you are checking a Custom Permission, it will only work if the Feature part of the Permission key (`org::`) **is a Feature included in the Organization's active Plan**. For example, say you want to check if an Organization member has the Custom Permission `org:teams:manage`, where `teams` is the Feature. Before performing the authorization check, you need to ensure that the user's Organization is subscribed to a Plan that has the `teams` Feature. If the user's Organization is not subscribed to a Plan that has the `teams` Feature, the authorization check will always return `false`, *even if the user has the Custom Permission*.
### Example: Using `has()`
Use the `has()` method to test if the Organization has access to a **Plan**:
```jsx
const hasPremiumAccess = has({ plan: 'gold' })
```
Or a **Feature**:
```jsx
const hasPremiumAccess = has({ feature: 'widgets' })
```
The has() method is a server-side helper that checks if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan) and returns a boolean value. `has()` is available on the auth object, which you will access differently depending on the framework you are using.
> \[!TIP]
> Why aren't Custom Permissions appearing in the session token (JWT) or in API responses (including the result of the `has()` check)?
>
> ***
>
> Custom Permissions will only appear in the session token (JWT) and in API responses (including the result of the `has()` check) if the Feature part of the Permission key (`org::`) **is a Feature included in the Organization's active Plan**. If the Feature is not part of the Plan, the `has()` check for Permissions using that Feature will return `false`, and those Permissions will not be represented in the session token.
>
> For example, say you want to check if an Organization member has the Custom Permission `org:teams:manage`, where `teams` is the Feature. The user's Organization must be subscribed to a Plan that has the `teams` Feature for authorization checks to work. If the user's Organization is not subscribed to a Plan that has the `teams` Feature, the authorization check will always return `false`, *even if the user has the Custom Permission*.
The following example demonstrates how to use `has()` to check if an Organization has a Plan.
```tsx {{ filename: 'app/routes/bronze-content.tsx' }}
import type { Route } from './+types/bronze-content'
import { useAuth } from '@clerk/react-router'
export function meta({}: Route.MetaArgs) {
return [{ title: 'Bronze Content' }]
}
export default function BronzeContentPage() {
const { has, isLoaded } = useAuth()
if (!isLoaded) return
Loading...
const hasBronzePlan = has({ plan: 'bronze' })
if (!hasBronzePlan) return
Only subscribers to the Bronze plan can access this content.
return
For Bronze subscribers only
}
```
The following example demonstrates how to use `has()` to check if an Organization has a Feature.
```tsx {{ filename: 'app/routes/premium-content.tsx' }}
import type { Route } from './+types/premium-content'
import { useAuth } from '@clerk/react-router'
export function meta({}: Route.MetaArgs) {
return [{ title: 'Page' }]
}
export default function PremiumContentPage() {
const { isLoaded, has } = useAuth()
if (!isLoaded) return
Loading...
const hasPremiumAccess = has({ feature: 'premium_access' })
if (!hasPremiumAccess)
return
Only subscribers with the Premium Access feature can access this content.
return
Our Exclusive Content
}
```
The following example demonstrates how to use `has()` to check if an Organization has a Permission.
```tsx {{ filename: 'app/routes/manage-premium-content.tsx' }}
import type { Route } from './+types/manage-premium-content'
import { useAuth } from '@clerk/react-router'
export function meta({}: Route.MetaArgs) {
return [{ title: 'Manage Premium Content' }]
}
export default function ManagePremiumContentPage() {
const { has, isLoaded } = useAuth()
if (!isLoaded) return
Only subscribers with the Premium Access Manage permission can access this content.
)
return
Our Exclusive Content
}
```
### Example: Using ``
The \ component protects content or even entire routes by checking if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan). You can pass a `fallback` prop to `` that will be rendered if the Organization does not have the access control.
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Plan.
```tsx {{ filename: 'app/routes/protected-content.tsx' }}
import type { Route } from './+types/protected-content'
import { Protect } from '@clerk/react-router'
export function meta({}: Route.MetaArgs) {
return [{ title: 'Protected Content' }]
}
export default function ProtectedContentPage() {
return (
Only subscribers to the Bronze plan can access this content.}
>
Exclusive Bronze Content
This content is only visible to Bronze subscribers.
)
}
```
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Feature.
```tsx {{ filename: 'app/routes/protected-premium-content.tsx' }}
import type { Route } from './+types/protected-premium-content'
import { Protect } from '@clerk/react-router'
export function meta({}: Route.MetaArgs) {
return [{ title: 'Protected Premium Content' }]
}
export default function ProtectedPremiumContentPage() {
return (
Only subscribers with the Premium Access feature can access this content.}
>
Exclusive Premium Content
This content is only visible to users with Premium Access feature.
)
}
```
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Permission.
```tsx {{ filename: 'app/routes/protected-manage-content.tsx' }}
import type { Route } from './+types/protected-manage-content'
import { Protect } from '@clerk/react-router'
export function meta({}: Route.MetaArgs) {
return [{ title: 'Protected Manage Content' }]
}
export default function ProtectedManageContentPage() {
return (
Only subscribers with the Premium Access Manage permission can access this content.
}
>
Exclusive Management Content
This content is only visible to users with Premium Access Manage permission.
)
}
```
---
title: Build your own sign-up page for your React Router app with Clerk
description: Learn how to add a custom sign-up page to your React Router app
with Clerk's prebuilt components.
sdk: nextjs, react-router, remix, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/guides/development/custom-sign-up-page
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,react-router,remix,tanstack-react-start
notAvailableSdks: react,js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/guides/development/custom-sign-up-page.react-router.mdx
---
By default, the \ component handles signing in and signing up, but if you'd like to have a dedicated sign-up page, this guide shows you how to use the \ component to build a custom sign-up page.
To set up a single sign-in-or-up page, follow the [custom sign-in-or-up page guide](/docs/react-router/guides/development/custom-sign-in-or-up-page).
> \[!NOTE]
> Just getting started with Clerk and React Router? See the [quickstart tutorial](/docs/react-router/getting-started/quickstart)!
## Build a sign-up page
The following example demonstrates how to render the \ component on a dedicated sign-up page using the [React Router Splat route](https://reactrouter.com/start/framework/routing#splats).
```tsx {{ filename: 'app/routes/sign-up.tsx' }}
import { SignUp } from '@clerk/react-router'
export default function SignUpPage() {
return (
Sign up route
)
}
```
## Configure routes
React Router expects you to define routes in [`app/routes.ts`](https://reactrouter.com/start/framework/routing). Add the previously created sign-up page to your route configuration.
```tsx {{ filename: 'app/routes.ts', mark: [6] }}
import { type RouteConfig, index, route } from '@react-router/dev/routes'
export default [
index('routes/home.tsx'),
route('sign-in/*', 'routes/sign-in.tsx'),
route('sign-up/*', 'routes/sign-up.tsx'),
] satisfies RouteConfig
```
## Configure redirect behavior
* Set the `CLERK_SIGN_UP_URL` environment variable to tell Clerk where the `` component is being hosted.
* Set `CLERK_SIGN_UP_FALLBACK_REDIRECT_URL` as a fallback URL incase users visit the `/sign-up` route directly.
* Set `CLERK_SIGN_IN_FALLBACK_REDIRECT_URL` as a fallback URL incase users select the 'Already have an account? Sign in' link at the bottom of the component.
Learn more about these environment variables and how to customize Clerk's redirect behavior in the [dedicated guide](/docs/guides/development/customize-redirect-urls).
```env {{ filename: '.env' }}
CLERK_SIGN_UP_URL=/sign-up
CLERK_SIGN_UP_FALLBACK_REDIRECT_URL=/
CLERK_SIGN_IN_FALLBACK_REDIRECT_URL=/
```
These values control the behavior of the `` and `` components and when you visit the respective links at the bottom of each component.
## Visit your new page
Run your project with the following command:
```npm
npm run dev
```
Visit your new custom page locally at [localhost:5173/sign-up](http://localhost:5173/sign-up).
---
title: Build your own sign-in-or-up page for your React Router app with Clerk
description: Learn how to add a custom sign-in-or-up page to your React Router
app with Clerk's prebuilt components.
sdk: nextjs, react-router, remix, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/guides/development/custom-sign-in-or-up-page
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,react-router,remix,tanstack-react-start
notAvailableSdks: react,js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/guides/development/custom-sign-in-or-up-page.react-router.mdx
---
This guide shows you how to use the \ component to build a custom page **that allows users to sign in or sign up within a single flow**.
To set up separate sign-in and sign-up pages, follow this guide, and then follow the [custom sign-up page guide](/docs/react-router/guides/development/custom-sign-up-page).
## Build a sign-in-or-up page
The following example demonstrates how to render the \ component on a dedicated page using the [React Router Splat route](https://reactrouter.com/start/framework/routing#splats).
```tsx {{ filename: 'app/routes/sign-in.tsx' }}
import { SignIn } from '@clerk/react-router'
export default function SignInPage() {
return (
Sign in or up route
)
}
```
## Configure routes
React Router expects you to define routes in [`app/routes.ts`](https://reactrouter.com/start/framework/routing). Add the previously created sign-in-or-up page to your route configuration.
```tsx {{ filename: 'app/routes.ts', mark: [5] }}
import { type RouteConfig, index, route } from '@react-router/dev/routes'
export default [
index('routes/home.tsx'),
route('sign-in/*', 'routes/sign-in.tsx'),
] satisfies RouteConfig
```
## Configure redirect behavior
* Set the `CLERK_SIGN_IN_URL` environment variable to tell Clerk where the `` component is being hosted.
* Set `CLERK_SIGN_IN_FALLBACK_REDIRECT_URL` as a fallback URL incase users visit the `/sign-in` route directly.
* Set `CLERK_SIGN_UP_FALLBACK_REDIRECT_URL` as a fallback URL incase users select the 'Don't have an account? Sign up' link at the bottom of the component.
Learn more about these environment variables and how to customize Clerk's redirect behavior in the [dedicated guide](/docs/guides/development/customize-redirect-urls).
```env {{ filename: '.env' }}
CLERK_SIGN_IN_URL=/sign-in
CLERK_SIGN_IN_FALLBACK_REDIRECT_URL=/
CLERK_SIGN_UP_FALLBACK_REDIRECT_URL=/
```
## Visit your new page
Run your project with the following command:
```npm
npm run dev
```
Visit your new custom page locally at [localhost:5173/sign-in](http://localhost:5173/sign-in).
## Next steps
* [Custom sign-up page](/docs/react-router/guides/development/custom-sign-up-page)
* Learn how to add a custom sign-up page to your React Router app with Clerk's prebuilt components.
---
title: Verify OAuth access tokens in your React Router application with Clerk
description: Learn how to use Clerk's helpers to verify OAuth access tokens in
your React Router application.
sdk: nextjs, react-router, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/guides/development/verifying-oauth-access-tokens
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,react-router,tanstack-react-start
notAvailableSdks: react,js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,remix,go,astro,nuxt,vue,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/guides/development/verifying-oauth-access-tokens.react-router.mdx
---
When building a resource server that needs to accept and verify OAuth access tokens issued by Clerk, it's crucial to verify these tokens on your backend to ensure the request is coming from an authenticated client.
> \[!NOTE]
> OAuth tokens are machine tokens. Machine token usage is free during our public beta period but will be subject to pricing once generally available. Pricing is expected to be competitive and below market averages.
Clerk provides a built-in [`getAuth()`](/docs/reference/react-router/get-auth) function that supports token validation via the `acceptsToken` parameter. This lets you specify which type(s) of token your API route should accept in your React Router app.
By default, `acceptsToken` is set to `session_token`, which means OAuth tokens will **not** be accepted unless explicitly configured. You can pass either a **single token type** or an **array of token types** to `acceptsToken`. To learn more about the supported token types, see the [`getAuth()` parameters documentation](/docs/reference/react-router/get-auth#parameters).
## Example 1: Accepting a single token type
In the following example, the `acceptsToken` parameter is set to only accept `oauth_token`s.
* If the token is invalid or missing, `auth()` will return `null` for `subject` and other properties, and the request will be rejected with a `401` response.
* If the token is valid, it returns the authenticated user's subject and their associated scopes for use in the application logic.
```tsx
import { getAuth } from '@clerk/react-router/server'
import type { Route } from './+types/profile'
export async function loader(args: Route.LoaderArgs) {
const { subject, scopes } = await getAuth(args, { acceptsToken: 'oauth_token' })
// If getAuth() returns null, the token is invalid
if (!subject) {
throw new Response('OAuth access token is invalid', { status: 401 })
}
return { subject, scopes }
}
```
## Example 2: Accepting any token type
In the following example, the `acceptsToken` parameter is set to accept any token type.
* If the token is a `session_token`, it logs that the request is from a user session.
* Otherwise, it logs that the request uses a machine token and specifies its type.
```tsx
import { getAuth } from '@clerk/react-router/server'
import type { Route } from './+types/profile'
export async function loader(args: Route.LoaderArgs) {
const { tokenType } = await getAuth(args, { acceptsToken: 'any' })
if (tokenType === 'session_token') {
console.log('This is a session token from a user')
} else {
console.log(`This is a ${tokenType} token`)
}
return { tokenType }
}
```
---
title: Clerk Billing webhooks
description: Clerk Billing webhooks allow you to track subscription lifecycles
and monitor payment attempts.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/development/webhooks/billing
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: react-router
sourceFile: /docs/guides/development/webhooks/billing.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing supports webhook events that allow you to track information like subscription lifecycles and payments.
## Subscriptions
A subscription is a top-level container unique to each user or organization. Subscription events can help you track billing changes for each of your customers.
| Event Name | Description |
| - | - |
| `subscription.created` | The top-level subscription is created. This usually happens when a user or organization is created. For existing users and organizations, a subscription will be created when Billing is enabled for the application. |
| `subscription.updated` | The top-level subscription is updated. This event is triggered when any property of the subscription has changed, except for status changes. For example, when the subscription items for the payer change. |
| `subscription.active` | The top-level subscription transitions to active from a non-active status. This happens when any subscription item is set to active, including items from the free default Plan. |
| `subscription.pastDue` | The top-level subscription contains a subscription item that has become past due. |
## Subscription items
A subscription item provides details about the relationship between the payer (user or Organization) and a Plan. A top-level subscription may contain multiple subscription items.
There can only be one `active` subscription item per payer and Plan. In addition, the subscription item for the default Plan will always have the same `id` to allow easier tracking of which users and Organizations are not paid customers.
| Event Name | Description |
| - | - |
| `subscriptionItem.updated` | The subscription item is updated. This event is triggered when a property of the subscription item has changed that does not result in a status change. For example, when a subscription item is renewed and the recurring monthly charge succeeds, the status doesn't change (remains `active`), but `period_start` and `period_end` are updated. This results in a `subscriptionItem.updated` event. |
| `subscriptionItem.active` | The subscription item is set to active. For paid Plans, this happens on successful payment. |
| `subscriptionItem.canceled` | The subscription item is canceled. The payer retains Plan features until the end of the current billing period. |
| `subscriptionItem.upcoming` | The subscription item is set as upcoming after the current billing period. This can happen in the case of a deferred Plan change from a higher-priced to lower-priced Plan. In the case a paid Plan is canceled, the subscription item for the default, free Plan will be set as `upcoming`. |
| `subscriptionItem.ended` | The subscription item has ended. |
| `subscriptionItem.abandoned` | The subscription item is abandoned. This can happen to `upcoming` subscription items if the payer subscribes to another Plan, or re-subscribes to a currently canceled Plan. |
| `subscriptionItem.incomplete` | The subscription item is incomplete. This means the payer has started a checkout for a Plan, but the payment hasn't been successfully processed yet. Once payment succeeds, the subscription item transitions to an `active` status. |
| `subscriptionItem.pastDue` | The subscription item is past due because a recurring charge has failed. |
| `subscriptionItem.freeTrialEnding` | The subscription item is a free trial and is ending soon. This event is sent three days before the trial ends. If the trial is shorter than three days, it's sent immediately. |
## Payment attempts
Payment attempts allow you to track successful and failed payments, for both checkout and recurring charges.
Payment attempt events contain a `type`, which can be either `checkout` or `recurring`. You can use these values to determine whether a payment attempt was for a checkout or a subscription item renewal's recurring charge.
| Event Name | Description |
| - | - |
| `paymentAttempt.created` | A payment attempt has been created with `pending` status. It can either succeed or fail in the future. |
| `paymentAttempt.updated` | A payment attempt has been updated to `paid` or `failed` status. |
Looking for other webhook events? To find a list of all the events Clerk supports, navigate to the [**Webhooks**](https://dashboard.clerk.com/~/webhooks) page and select the **Event Catalog** tab.
---
title: Protect content and read user data
description: Learn how to use Clerk's hooks and helpers to protect content and
read user data in your React Router application.
metadata:
title: Read session and user data in your React Router app with Clerk
sdk: nextjs, expo, react-router, remix, tanstack-react-start, astro, nuxt
sdkScoped: "true"
canonical: /docs/:sdk:/guides/users/reading
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,expo,react-router,remix,tanstack-react-start,astro,nuxt
notAvailableSdks: react,js-frontend,chrome-extension,android,ios,expressjs,fastify,go,vue,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/guides/users/reading.react-router.mdx
---
Clerk provides a set of [hooks and helpers](/docs/reference/react-router/overview#client-side-helpers) that you can use to protect content and read user data in your React Router application. This guide demonstrates how to use these helpers in both the client and server-side to get you started.
## Server-side
To access active session and user data on the server-side, use the [`getAuth()`](/docs/reference/react-router/get-auth) helper.
### Server data loading
The [`getAuth()`](/docs/reference/react-router/get-auth) helper returns the Auth object of the currently active user, which contains important information like the current user's session ID, user ID, and Organization ID, and the `isAuthenticated` property, which can be used to protect your API routes.
In some cases, you may need the full Backend User object of the currently active user. This is helpful if you want to render information, like their first and last name, directly from the server. The `clerkClient()` helper returns an instance of the JS Backend SDK, which exposes Clerk's Backend API resources through methods such as the getUser(){{ target: '_blank' }} method. This method returns the full `Backend User` object.
In the following example, the `userId` is passed to the JS Backend SDK's `getUser()` method to get the user's full `Backend User` object.
```tsx {{ filename: 'app/routes/profile.tsx' }}
import { redirect } from 'react-router'
import { clerkClient, getAuth } from '@clerk/react-router/server'
import type { Route } from './+types/profile'
export async function loader(args: Route.LoaderArgs) {
// Use `getAuth()` to access `isAuthenticated` and the user's ID
const { isAuthenticated, userId } = await getAuth(args)
// Protect the route by checking if the user is signed in
if (!isAuthenticated) {
return redirect('/sign-in?redirect_url=' + args.request.url)
}
// Get the user's full `Backend User` object
const user = await clerkClient(args).users.getUser(userId)
return {
user: JSON.stringify(user),
}
}
export default function Profile({ loaderData }: Route.ComponentProps) {
return (
Profile Data
{JSON.stringify(loaderData, null, 2)}
)
}
```
### Server action
Unlike the previous example that loads data when the page loads, the following example uses `getAuth()` to only fetch user data after submitting the form. The helper runs on form submission, authenticates the user, and processes the form data.
```tsx {{ filename: 'app/routes/profile-form.tsx' }}
import { redirect, Form } from 'react-router'
import { clerkClient, getAuth } from '@clerk/react-router/server'
import type { Route } from './+types/profile-form'
export async function action(args: Route.ActionArgs) {
// Use `getAuth()` to access `isAuthenticated` and the user's ID
const { isAuthenticated, userId } = await getAuth(args)
// Protect the route by checking if the user is signed in
if (!isAuthenticated) {
return redirect('/sign-in?redirect_url=' + args.request.url)
}
// Get the form data
const formData = await args.request.formData()
const name = formData.get('name')?.toString()
// Get the user's full `Backend User` object
const user = await clerkClient(args).users.getUser(userId)
return {
name,
user: JSON.stringify(user),
}
}
export default function ProfileForm({ actionData }: Route.ComponentProps) {
return (
Profile Data
{actionData ? (
{JSON.stringify(actionData, null, 2)}
) : null}
)
}
```
## Client-side
To access session and user data on the client-side, you can use the `useAuth()` and `useUser()` hooks.
### `useAuth()`
{/* TODO: Keep in sync with /tanstack-react-start/read-session-data and /expo/read-session-user-data */}
The following example uses the useAuth() hook to access the current auth state, as well as helper methods to manage the current session.
```tsx {{ filename: 'example.tsx' }}
export default function Example() {
const { isLoaded, isSignedIn, userId, sessionId, getToken } = useAuth()
const fetchExternalData = async () => {
// Use `getToken()` to get the current user's session token
const token = await getToken()
// Use `token` to fetch data from an external API
const response = await fetch('https://api.example.com/data', {
headers: {
Authorization: `Bearer ${token}`,
},
})
return response.json()
}
// Use `isLoaded` to check if Clerk is loaded
if (!isLoaded) {
return
Loading...
}
// Use `isSignedIn` to check if the user is signed in
if (!isSignedIn) {
// You could also add a redirect to the sign-in page here
return
Sign in to view this page
}
return (
Hello, {userId}! Your current active session is {sessionId}.
)
}
```
### `useUser()`
{/* TODO: Keep in sync with /reference/tanstack-react-start/read-session-data and /reference/expo/read-session-user-data */}
The following example uses the useUser() hook to access the User object, which contains the current user's data such as their full name. The following example demonstrates how to use `useUser()` to check if the user is signed in and display their first name.
```tsx {{ filename: 'src/Example.tsx' }}
export default function Example() {
const { isSignedIn, user, isLoaded } = useUser()
// Use `isLoaded` to check if Clerk is loaded
if (!isLoaded) {
return
Loading...
}
// Use `isSignedIn` to protect the content
if (!isSignedIn) {
return
Sign in to view this page
}
// Use `user` to access the current user's data
return
Hello {user.firstName}!
}
```
---
title: "``"
description: The component provides session and user context to
Clerk's hooks and components.
sdk: chrome-extension, expo, nextjs, react, react-router, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/clerk-provider
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: chrome-extension,expo,nextjs,react,react-router,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,remix,go,astro,nuxt,vue,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/clerk-provider.mdx
---
The `` component is required to integrate Clerk into your React application, providing session and user context to Clerk's hooks and components.
The recommended approach is to wrap your entire app with `` at the entry point to make authentication globally accessible. If you only need authentication for specific routes or pieces of your application, render `` deeper in the component tree. This allows you to implement Clerk's functionality precisely where required without impacting the rest of your app.
## Example
```tsx {{ filename: 'app/root.tsx' }}
// Other imports
import { ClerkProvider, SignedIn, SignedOut, UserButton, SignInButton } from '@clerk/react-router'
export default function App({ loaderData }: Route.ComponentProps) {
return (
)
}
// Rest of the root.tsx code
```
## Properties
| Property | Type | Description |
| ----------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `afterMultiSessionSingleSignOutUrl?` | null \| string | The full URL or path to navigate to after signing out the current user is complete. This option applies to [multi-session applications](/docs/guides/secure/session-options#multi-session-applications). |
| ~~`afterSignInUrl?`~~ | null \| string | **Deprecated.** Use `signInFallbackRedirectUrl` or `signInForceRedirectUrl` instead. |
| `afterSignOutUrl?` | null \| string | Full URL or path to navigate to after successful sign out. |
| ~~`afterSignUpUrl?`~~ | null \| string | **Deprecated.** Use `signUpFallbackRedirectUrl` or `signUpForceRedirectUrl` instead. |
| `allowedRedirectOrigins?` | (string \| RegExp)\[] | An optional array of domains to validate user-provided redirect URLs against. If no match is made, the redirect is considered unsafe and the default redirect will be used with a warning logged in the console. |
| `allowedRedirectProtocols?` | string\[] | An optional array of protocols to validate user-provided redirect URLs against. If no match is made, the redirect is considered unsafe and the default redirect will be used with a warning logged in the console. |
| `appearance?` | [`Appearance`](/docs/guides/customizing-clerk/appearance-prop/overview) | Optional object to style your components. Will only affect Clerk Components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages. |
| `clerkJSUrl?` | `string` | The URL that `@clerk/clerk-js` should be hot-loaded from. |
| `clerkJSVariant?` | "" \| "headless" | If your web application only uses Control Components, you can set this value to `'headless'` and load a minimal ClerkJS bundle for optimal page performance. |
| `clerkJSVersion?` | `string` | The npm version for `@clerk/clerk-js`. |
| `domain?` | string \| (url: URL) => string | **Required if your application is a satellite application**. Sets the domain of the satellite application. |
| `experimental?` | `Autocomplete`\<\{ commerce: boolean; persistClient: boolean; rethrowOfflineNetworkErrors: boolean; \}, `Record`\<`string`, `any`\>\> | Enable experimental flags to gain access to new features. These flags are not guaranteed to be stable and may change drastically in between patch or minor versions. |
| `initialState?` | `Serializable`\<\{ actor: undefined \| \{ \[x: string]: unknown; sub: string; \}; factorVerificationAge: \[number, number]; organization: undefined \| OrganizationResource; orgId: undefined \| string; orgPermissions: undefined \| string\[]; orgRole: undefined \| string; orgSlug: undefined \| string; session: undefined \| SessionResource; sessionClaims: JwtPayload; sessionId: undefined \| string; sessionStatus: SessionStatusClaim; user: undefined \| UserResource; userId: undefined \| string; \}\> | Provide an initial state of the Clerk client during server-side rendering. You don't need to set this value yourself unless you're [developing an SDK](/docs/guides/development/sdk-development/overview). |
| `isSatellite?` | boolean \| (url: URL) => boolean | A boolean that indicates whether the application is a satellite application. |
| `localization?` | [`LocalizationResource`](/docs/guides/customizing-clerk/localization) | Optional object to localize your components. Will only affect Clerk Components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages. |
| `newSubscriptionRedirectUrl?` | null \| string | The URL to navigate to after the user completes the checkout and clicks the "Continue" button. |
| `nonce?` | `string` | This nonce value will be passed through to the `@clerk/clerk-js` script tag. Use it to implement a [strict-dynamic CSP](/docs/guides/secure/best-practices/csp-headers#implementing-a-strict-dynamic-csp). Requires the `dynamic` prop to also be set. |
| `proxyUrl?` | string \| (url: URL) => string \| (url: URL) => string | **Required for applications that run behind a reverse proxy**. The URL that Clerk will proxy requests to. Can be either a relative path (`/__clerk`) or a full URL (`https:///__clerk`). |
| `publishableKey` | `string` | The Clerk Publishable Key for your instance. This can be found on the [API keys](https://dashboard.clerk.com/last-active?path=api-keys) page in the Clerk Dashboard. |
| ~~`redirectUrl?`~~ | null \| string | **Deprecated.** Use `signInFallbackRedirectUrl`, `signInForceRedirectUrl`, `signUpFallbackRedirectUrl`, or `signUpForceRedirectUrl` instead. |
| `routerPush?` | (to: string, metadata?: \{ windowNavigate: (to: string \| URL) => void; \}) => unknown | A function which takes the destination path as an argument and performs a "push" navigation. |
| `routerReplace?` | (to: string, metadata?: \{ windowNavigate: (to: string \| URL) => void; \}) => unknown | A function which takes the destination path as an argument and performs a "replace" navigation. |
| `sdkMetadata?` | \{ environment?: string; name: string; version: string; \} | Contains information about the SDK that the host application is using. You don't need to set this value yourself unless you're [developing an SDK](/docs/guides/development/sdk-development/overview). |
| `sdkMetadata.environment?` | `string` | Typically this will be the `NODE_ENV` that the SDK is currently running in. |
| `sdkMetadata.name` | `string` | The npm package name of the SDK. |
| `sdkMetadata.version` | `string` | The npm package version of the SDK. |
| `selectInitialSession?` | (client: ClientResource) => null \| SignedInSessionResource | By default, the last signed-in session is used during client initialization. This option allows you to override that behavior, e.g. by selecting a specific session. |
| `signInFallbackRedirectUrl?` | null \| string | The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. It's recommended to use the [environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead. Defaults to `'/'`. |
| `signInForceRedirectUrl?` | null \| string | This URL will always be redirected to after the user signs in. It's recommended to use the [environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead. |
| `signInUrl?` | `string` | This URL will be used for any redirects that might happen and needs to point to your primary application on the client-side. This option is optional for production instances. **It is required to be set for a satellite application in a development instance**. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead. |
| `signUpFallbackRedirectUrl?` | null \| string | The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. It's recommended to use the [environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead. Defaults to `'/'`. |
| `signUpForceRedirectUrl?` | null \| string | This URL will always be redirected to after the user signs up. It's recommended to use the [environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead. |
| `signUpUrl?` | `string` | This URL will be used for any redirects that might happen and needs to point to your primary application on the client-side. This option is optional for production instances but **must be set for a satellite application in a development instance**. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead. |
| `standardBrowser?` | `boolean` | By default, ClerkJS is loaded with the assumption that cookies can be set (browser setup). On native platforms this value must be set to `false`. |
| `supportEmail?` | `string` | Optional support email for display in authentication screens. Will only affect Clerk Components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages. |
| `taskUrls?` | `Record`\<`"choose-organization"`, `string`\> | Customize the URL paths users are redirected to after sign-in or sign-up when specific session tasks need to be completed. When `undefined`, it uses Clerk's default task flow URLs. Defaults to `undefined`. |
| `telemetry?` | false \| \{ debug?: boolean; disabled?: boolean; perEventSampling?: boolean; \} | Controls whether or not Clerk will collect [telemetry data](/docs/guides/how-clerk-works/security/clerk-telemetry). If set to `debug`, telemetry events are only logged to the console and not sent to Clerk. |
| `touchSession?` | `boolean` | By default, the [Clerk Frontend API `touch` endpoint](/docs/reference/frontend-api/tag/Sessions#operation/touchSession) is called during page focus to keep the last active session alive. This option allows you to disable this behavior. |
| `waitlistUrl?` | `string` | The full URL or path to the waitlist page. If `undefined`, will redirect to the [Account Portal waitlist page](/docs/guides/customizing-clerk/account-portal#waitlist). |
## SDK-specific properties
### Next.js
* `dynamic`
* `boolean`
Indicates whether or not Clerk should make dynamic auth data available based on the current request. Defaults to `false`. Opts the application into dynamic rendering when `true`. For more information, see Next.js rendering modes and Clerk.
### Chrome Extension
* `syncHost`
* `string`
To enable, pass the URL of the web application that the extension will sync the authentication state from. See the dedicated guide for more information.
---
title: Component Reference
description: A list of Clerk's comprehensive suite of components designed to
seamlessly integrate authentication and multi-tenancy into your application.
sdk: react, nextjs, js-frontend, chrome-extension, expo, android, expressjs,
fastify, react-router, remix, tanstack-react-start, go, astro, nuxt, vue,
ruby, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/overview
lastUpdated: 2025-11-21T23:29:30.000Z
availableSdks: react,nextjs,js-frontend,chrome-extension,expo,android,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
notAvailableSdks: ios
activeSdk: react-router
sourceFile: /docs/reference/components/overview.mdx
---
Clerk offers a comprehensive suite of components designed to seamlessly integrate authentication and multi-tenancy into your application. With Clerk components, you can easily customize the appearance of authentication components and pages, manage the entire authentication flow to suit your specific needs, and even build robust SaaS applications.
## Authentication components
* \
* \
* \
* \
* \
## User components
* \
* \
* \
## Organization components
* \
* \
* \
* \
## Billing components
* \
* \
* \
* \
## Control components
Control components manage authentication-related behaviors in your application. They handle tasks such as controlling content visibility based on user authentication status, managing loading states during authentication processes, and redirecting users to appropriate pages. Control components render at `` and `` states for assertions on the Clerk object. A common example is the \ component, which allows you to conditionally render content only when a user is authenticated.
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
## Unstyled components
* \
* \
* \
* \
## Customization guides
* [Customize components with the `appearance` prop](/docs/guides/customizing-clerk/appearance-prop/overview)
* [Localize components with the `localization` prop (experimental)](/docs/guides/customizing-clerk/localization)
* [Add pages to the `` component](/docs/guides/customizing-clerk/adding-items/user-profile)
* [Add pages to the `` component](/docs/guides/customizing-clerk/adding-items/organization-profile)
### Secured by Clerk branding
> \[!WARNING]
> This feature requires a [paid plan](/pricing){{ target: '_blank' }} for production use, but all features are free to use in development mode so that you can try out what works for you. See the [pricing](/pricing){{ target: '_blank' }} page for more information.
By default, Clerk displays a **Secured by Clerk** badge on Clerk components. You can remove this branding by following these steps:
1. In the Clerk Dashboard, navigate to your application's [**Settings**](https://dashboard.clerk.com/~/settings).
2. Under **Branding**, toggle on the **Remove "Secured by Clerk" branding** option.
* [Join our Discord](https://clerk.com/discord "Join Discord")
* Join our official Discord server to chat with us directly and become a part of the Clerk community.
* {}
***
* [Need help?](/support "Get help")
* Contact us through Discord, Twitter, or email to receive answers to your questions and learn more about Clerk.
* {}
---
title: "`` component"
description: Clerk's component renders a UI for authenticating
users with Google's One Tap API.
sdk: astro, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/authentication/google-one-tap
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: chrome-extension,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/authentication/google-one-tap.mdx
---
> \[!IMPORTANT]
> To use Google One Tap with Clerk, you must [enable Google as a social connection in the Clerk Dashboard](/docs/guides/configure/auth-strategies/social-connections/google#configure-for-your-production-instance) and make sure to use custom credentials.
The `` component renders the [Google One Tap](https://developers.google.com/identity/gsi/web/guides/features) UI so that users can use a single button to sign-up or sign-in to your Clerk application with their Google accounts.
By default, this component will redirect users back to the page where the authentication flow started. However, you can override this with force redirect URL props or [force redirect URL environment variables](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects).
> \[!TIP]
> `` does not render if the user is already signed into your Clerk application, so there's no need to manually check if a user is signed in yourself before rendering it.
## Example
The following example includes basic implementation of the `` component. You can use this as a starting point for your own implementation.
```tsx {{ filename: 'app/routes/sign-in.tsx' }}
import { GoogleOneTap } from '@clerk/react-router'
export default function Page() {
return
}
```
## Properties
* `cancelOnTapOutside?`
* `boolean`
If `true`, the One Tap prompt closes automatically if the user clicks outside of the prompt. Defaults to `true`.
***
* `itpSupport?`
* `boolean`
If `true`, enables the [ITP-specific UX](https://developers.google.com/identity/gsi/web/guides/itp) when One Tap is rendered on ITP browsers such as Chrome on iOS, Safari, and FireFox. Defaults to `true`.
***
* `fedCmSupport?`
* `boolean`
If `true`, enables Google One Tap to use [the FedCM API](https://developers.google.com/privacy-sandbox/3pcd/fedcm) to sign users in. See Google's docs on [best practices when disabling FedCM support](https://developers.google.com/identity/gsi/web/guides/display-google-one-tap#do_not_cover_google_one_tap). Defaults to `true`
***
* `signInForceRedirectUrl?`
* `string`
Useful if you want to redirect to a path specific to Google One Tap users. If provided, this URL will **always** be redirected to after the user signs in, overriding any \ redirect URL props or [redirect URL environment variables](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects).
***
* `signUpForceRedirectUrl?`
* `string`
Useful if you want to redirect to a path specific to Google One Tap users. If provided, this URL will **always** be redirected to after the user signs up, overriding any \ redirect URL props or [redirect URL environment variables](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects).
## Limitations
* If your application will use the Google API on behalf of your users, the `` component is not recommended, as Google does not provide Clerk with an access or refresh token that you can use.
* Users with the 1Password browser extension may not be able to render the Google One Tap UI. They must disable this extension.
* When testing in development, if you select the `X` button to close the Google One Tap UI, you may encounter [a cooldown](https://developers.google.com/identity/gsi/web/guides/features#exponential_cooldown) that prevents you from rendering it again for a period of time. To bypass the cooldown, remove the `g_state` cookie.
---
title: "`` component"
description: Clerk's component renders a UI for
resolving the `choose-organization` task.
sdk: js-frontend, nextjs, react, react-router, remix, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/authentication/task-choose-organization
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: js-frontend,nextjs,react,react-router,remix,tanstack-react-start
notAvailableSdks: chrome-extension,expo,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/authentication/task-choose-organization.mdx
---
{{ style: { maxWidth: '460px' } }}
The `` component renders a UI for resolving the `choose-organization` session task. The functionality of the `` component is controlled by the instance settings you specify in the [Clerk Dashboard](https://dashboard.clerk.com), such as [sign-in and sign-up options](/docs/guides/configure/auth-strategies/sign-up-sign-in-options) and [social connections](/docs/guides/configure/auth-strategies/social-connections/overview). You can further customize your `` component by passing additional properties at the time of rendering.
> \[!IMPORTANT]
> The `` component cannot render when a user doesn't have current session tasks.
## Example
The following example demonstrates how to host the `` component on a custom page.
> \[!NOTE]
> To see the full `root.tsx` setup you need for Clerk with React Router, see the [React Router quickstart](/docs/react-router/getting-started/quickstart).
```tsx {{ filename: 'app/root.tsx', mark: [6] }}
import { ClerkProvider } from '@clerk/react-router'
import { Outlet } from 'react-router'
export default function App() {
return (
)
}
```
The `` component must be used in conjunction with the `` component. See the [dedicated guide on how to self-host the `` component](/docs/react-router/guides/development/custom-sign-in-or-up-page).
```tsx {{ filename: 'app/routes/onboarding/choose-organization.tsx' }}
import { TaskChooseOrganization } from '@clerk/react-router'
export default function ChooseOrganizationPage() {
return
}
```
## Properties
All props are optional.
* `redirectUrlComplete`
* `string`
The full URL or path to navigate to after successfully completing all tasks.
***
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
If Clerk's prebuilt components don't meet your specific needs or if you require more control over the logic, you can rebuild the existing Clerk flows using the Clerk API. For more information, see the [custom flow guides](/docs/guides/development/custom-flows/overview).
---
title: "`` component"
description: Clerk's component renders a UI for signing up users.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/authentication/sign-up
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/authentication/sign-up.mdx
---
{{ style: { maxWidth: '460px' } }}
The `` component renders a UI for signing up users. The functionality of the `` component is controlled by the instance settings you specify in the [Clerk Dashboard](https://dashboard.clerk.com), such as [sign-in and sign-up options](/docs/guides/configure/auth-strategies/sign-up-sign-in-options) and [social connections](/docs/guides/configure/auth-strategies/social-connections/all-providers). You can further customize your `` component by passing additional properties at the time of rendering.
> \[!NOTE]
> The `` and `` components cannot render when a user is already signed in, unless the application allows multiple sessions. If a user is already signed in and the application only allows a single session, Clerk will redirect the user to the Home URL instead.
## Example
The following example includes basic implementation of the `` component. You can use this as a starting point for your own implementation.
If you would like to create a dedicated `/sign-up` page in your React Router application, there are a few requirements you must follow. See the [dedicated guide](/docs/react-router/guides/development/custom-sign-up-page) for more information.
```tsx {{ filename: 'app/routes/sign-up.tsx' }}
import { SignUp } from '@clerk/react-router'
export default function SignUpPage() {
return
}
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `fallbackRedirectUrl`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `forceRedirectUrl`
* `string`
If provided, this URL will always be used as the redirect destination after the user signs up. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `initialValues`
* SignUpInitialValues
The values used to prefill the sign-up fields with.
***
* `oauthFlow`
* `"redirect" | "popup" | "auto"`
Determines how OAuth authentication is performed. Accepts the following properties:
* `"redirect"`: Redirect to the OAuth provider on the current page.
* `"popup"`: Open a popup window.
* `"auto"`: Choose the best method based on whether the current domain typically requires the `"popup"` flow to correctly perform authentication.
Defaults to `"auto"`.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash-based routing. For example: `/sign-up`.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
***
* `signInFallbackRedirectUrl`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Used for the 'Already have an account? Sign in' link that's rendered. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signInForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs in. Used for the 'Already have an account? Sign in' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signInUrl`
* `string`
The full URL or path to the sign-in page. Used for the 'Already have an account? Sign in' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `unsafeMetadata`
* SignUpUnsafeMetadata
Metadata that can be read and set from the frontend and the backend. Once the sign-up is complete, the value of this field will be automatically copied to the created user's unsafe metadata (`User.unsafeMetadata`). One common use case is to collect custom information about the user during the sign-up process and store it in this property. Read more about [unsafe metadata](/docs/guides/users/extending#unsafe-metadata).
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
If Clerk's prebuilt components don't meet your specific needs or if you require more control over the logic, you can rebuild the existing Clerk flows using the Clerk API. For more information, see the [custom flow guides](/docs/guides/development/custom-flows/overview).
---
title: "`` component"
description: The component renders a waitlist form that allows
users to join for early access to your application.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/authentication/waitlist
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/authentication/waitlist.mdx
---
{{ style: { maxWidth: '460px' } }}
In **Waitlist** mode, users can register their interest in your app by joining a waitlist. This mode is ideal for apps in early development stages or those wanting to generate interest before launch. [Learn more about additional features available in **Waitlist** mode](/docs/guides/secure/restricting-access#waitlist).
The `` component renders a form that allows users to join for early access to your app.
## Enable Waitlist mode
Before using the `` component, you must enable **Waitlist** mode in the Clerk Dashboard:
1. In the Clerk Dashboard, navigate to the [**Restrictions**](https://dashboard.clerk.com/~/user-authentication/restrictions) page.
2. Under the **Sign-up modes** section, enable **Waitlist**.
## Example
> \[!WARNING]
> Before using the `` component, you must provide the `waitlistUrl` prop either in the \ or \ component to ensure proper functionality.
The following example includes a basic implementation of the `` component. You can use this as a starting point for your own implementation.
```tsx {{ filename: 'app/routes/waitlist.tsx' }}
import { Waitlist } from '@clerk/react-router'
export default function WaitlistPage() {
return
}
```
## Properties
All props are optional.
* `afterJoinWaitlistUrl`
* `string`
The full URL or path to navigate to after joining the waitlist.
***
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `signInUrl`
* `string`
The full URL or path to the sign in page. Used for the 'Already have an account? Sign in' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
## Customization
To learn about how to customize Clerk components, see the [customization guide](/docs/guides/customizing-clerk/appearance-prop/overview).
---
title: "`` component"
description: Clerk's component renders a UI for signing in users.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/authentication/sign-in
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/authentication/sign-in.mdx
---
{{ style: { maxWidth: '460px' } }}
The `` component renders a UI to allow users to sign in or sign up by default. The functionality of the `` component is controlled by the instance settings you specify in the [Clerk Dashboard](https://dashboard.clerk.com), such as [sign-in and sign-up options](/docs/guides/configure/auth-strategies/sign-up-sign-in-options) and [social connections](/docs/guides/configure/auth-strategies/social-connections/all-providers). You can further customize your `` component by passing additional properties at the time of rendering.
> \[!NOTE]
> The `` and `` components cannot render when a user is already signed in, unless the application allows multiple sessions. If a user is already signed in and the application only allows a single session, Clerk will redirect the user to the Home URL instead.
## Example
The following example includes basic implementation of the `` component. You can use this as a starting point for your own implementation.
If you would like to create a dedicated `/sign-in` page in your React Router application, there are a few requirements you must follow. See the [dedicated guide](/docs/react-router/guides/development/custom-sign-in-or-up-page) for more information.
```tsx {{ filename: 'app/routes/sign-in.tsx' }}
import { SignIn } from '@clerk/react-router'
export default function SignInPage() {
return
}
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `fallbackRedirectUrl`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `forceRedirectUrl`
* `string`
If provided, this URL will always be redirected to after the user signs in. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `initialValues`
* SignInInitialValues
The values used to prefill the sign-in fields with.
***
* `oauthFlow`
* `"redirect" | "popup" | "auto"`
Determines how OAuth authentication is performed. Accepts the following properties:
* `"redirect"`: Redirect to the OAuth provider on the current page.
* `"popup"`: Open a popup window.
* `"auto"`: Choose the best method based on whether the current domain typically requires the `"popup"` flow to correctly perform authentication.
Defaults to `"auto"`.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash-based routing. For example: `/sign-in`.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
***
* `signUpFallbackRedirectUrl`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Used for the 'Don't have an account? Sign up' link that's rendered. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpForceRedirectUrl`
* `string`
If provided, this URL will always used as the redirect destination after the user signs up. Used for the 'Don't have an account? Sign up' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpUrl`
* `string`
The full URL or path to the sign-up page. Used for the 'Don't have an account? Sign up' link that's rendered. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `transferable`
* `boolean`
Indicates whether or not sign in attempts are transferable to the sign up flow. Defaults to `true`. When set to `false`, prevents opaque sign ups when a user attempts to sign in via OAuth with an email that doesn't exist.
***
* `waitlistUrl`
* `string`
Full URL or path to the waitlist page. Use this property to provide the target of the 'Waitlist' link that's rendered. If `undefined`, will redirect to the [Account Portal waitlist page](/docs/guides/customizing-clerk/account-portal#waitlist). If you've passed the `waitlistUrl` prop to the \ component, it will infer from that, and you can omit this prop.
***
* `withSignUp`
* `boolean`
Opt into sign-in-or-up flow by setting this prop to `true`. When `true`, if a user does not exist, they will be prompted to sign up. If a user exists, they will be prompted to sign in. Defaults to `true` if the `CLERK_SIGN_IN_URL` environment variable is set. Otherwise, defaults to `false`.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
If Clerk's prebuilt components don't meet your specific needs or if you require more control over the logic, you can rebuild the existing Clerk flows using the Clerk API. For more information, see the [custom flow guides](/docs/guides/development/custom-flows/overview).
---
title: "``"
description: Clerk's component displays a table of Plans and
Features that users can subscribe to.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/billing/pricing-table
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/billing/pricing-table.mdx
---

The `` component displays a table of Plans and Features that users can subscribe to.
## Example
The following example includes a basic implementation of the `` component. You can use this as a starting point for your own implementation.
```tsx {{ filename: 'app/routes/pricing.tsx' }}
import { PricingTable } from '@clerk/react-router'
export default function PricingPage() {
return
}
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `checkoutProps`
* `{ appearance: Appearance }`
Options for the checkout drawer. Accepts the following properties:
* [`appearance`](/docs/guides/customizing-clerk/appearance-prop/overview): an object used to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `collapseFeatures`
* `boolean`
A boolean that indicates whether the Features are collapsed. **Requires `layout` to be set to `'default'`**. Defaults to `false`.
***
* `ctaPosition`
* `'top' | 'bottom'`
The placement of the CTA button. **Requires `layout` to be set to `'default'`**. Defaults to `'bottom'`.
***
* `fallback`
* `JSX`
An optional UI to show when the pricing table is loading.
***
* `for`
* `'user' | 'organization'`
A string that indicates whether the pricing table is for users or [Organizations](/docs/guides/organizations/overview). If `'user'`, the pricing table will display a list of Plans and Features that **users** can subscribe to. If `'organization'`, the pricing table will display a list of Plans and Features that **Organizations** can subscribe to. Defaults to `'user'`.
***
* `newSubscriptionRedirectUrl`
* `string`
The URL to navigate to after the user completes the checkout and selects the "Continue" button.
---
title: "``"
description: The component indicates that Clerk is partially operational.
sdk: nextjs, react, react-router, chrome-extension, remix, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/clerk-degraded
lastUpdated: 2025-11-21T22:25:46.000Z
availableSdks: nextjs,react,react-router,chrome-extension,remix,tanstack-react-start
notAvailableSdks: js-frontend,expo,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/control/clerk-degraded.mdx
---
The `` component indicates that Clerk is partially operational.
## Example
It's not recommended to wrap the entire app in control components; instead, only wrap the components that need access to the `Clerk` object, such as custom flowsA **custom flow** refers to a user interface built entirely from scratch using the Clerk API. Learn more about [custom flows](/docs/guides/development/custom-flows/overview)..
```tsx {{ filename: 'app/routes/example.tsx' }}
import { ClerkLoading, ClerkLoaded, ClerkDegraded, ClerkFailed } from '@clerk/react-router'
export default function Example() {
return (
<>
Clerk is loading...
Clerk has loaded (ready or degraded)
Clerk is experiencing issues. Please try again later.
Something went wrong with Clerk. Please contact support.
>
)
}
```
---
title: "``"
description: The component indicates that the Clerk object has failed to load.
sdk: nextjs, react, react-router, chrome-extension, remix, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/clerk-failed
lastUpdated: 2025-11-21T22:25:46.000Z
availableSdks: nextjs,react,react-router,chrome-extension,remix,tanstack-react-start
notAvailableSdks: js-frontend,expo,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/control/clerk-failed.mdx
---
The `` component indicates that the Clerk object has failed to load. This is useful for displaying an error message to the user.
## Example
It's not recommended to wrap the entire app in control components; instead, only wrap the components that need access to the `Clerk` object, such as custom flowsA **custom flow** refers to a user interface built entirely from scratch using the Clerk API. Learn more about [custom flows](/docs/guides/development/custom-flows/overview)..
```tsx {{ filename: 'app/routes/example.tsx' }}
import { ClerkLoading, ClerkLoaded, ClerkDegraded, ClerkFailed } from '@clerk/react-router'
export default function Example() {
return (
<>
Clerk is loading...
Clerk has loaded (ready or degraded)
Clerk is experiencing issues. Please try again later.
Something went wrong with Clerk. Please contact support.
>
)
}
```
---
title: "``"
description: The `` component guarantees that the Clerk object has
loaded and will be available under `window.Clerk`. This allows you to wrap
child components to access the Clerk object without the need to check it
exists.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/clerk-loaded
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/control/clerk-loaded.mdx
---
The `` component guarantees that the Clerk object has loaded (the `status` is `'ready'` or `'degraded'`) and will be available under `window.Clerk`. This allows you to wrap child components to access the `Clerk` object without the need to check it exists.
## Example
It's not recommended to wrap the entire app in the `` component; instead, only wrap the components that need access to the `Clerk` object.
```tsx {{ filename: 'app/routes/example.tsx' }}
import { ClerkLoading, ClerkLoaded, ClerkDegraded, ClerkFailed } from '@clerk/react-router'
export default function Example() {
return (
<>
Clerk is loading...
Clerk has loaded (ready or degraded)
Clerk is experiencing issues. Please try again later.
Something went wrong with Clerk. Please contact support.
>
)
}
```
---
title: \RedirectCallback />
description: Clerk's `` component is used to
implement custom OAuth flows. It handles the OAuth callback and completes the
authentication process.
sdk: astro, chrome-extension, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/authenticate-with-redirect-callback
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: expo,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/control/authenticate-with-redirect-callback.mdx
---
The `` component is a crucial part of implementing custom OAuth flows in your application. It serves as the callback handler for the authentication process initiated by the `authenticateWithRedirect()` method. Render it on the route specified as the `redirectUrl` in your `authenticateWithRedirect()` call.
This component automatically handles the OAuth callback, completing the authentication process and managing the user's session. It uses the handleRedirectCallback() method under the hood.
## Example
For an example of how to use the `` component, see the [custom flow](/docs/guides/development/custom-flows/authentication/oauth-connections) guide.
## Properties
All props are optional.
* `continueSignUpUrl?`
* `string | undefined | null`
The full URL or path to navigate to if the sign up requires additional information.
***
* `signInUrl?`
* `string`
The full URL or path where the `` component is mounted.
***
* `signUpUrl?`
* `string`
The full URL or path where the `` component is mounted.
***
* `signInFallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpFallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signInForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs in. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs up. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `firstFactorUrl?`
* `string | undefined`
The full URL or path to navigate to during sign in, if first factor verification is required.
***
* `secondFactorUrl?`
* `string | undefined`
The full URL or path to navigate to during sign in, if [multi-factor authentication](/docs/guides/configure/auth-strategies/sign-up-sign-in-options#multi-factor-authentication) is enabled.
***
* `resetPasswordUrl?`
* `string`
The full URL or path to navigate to during sign in, if the user is required to reset their password.
***
* `transferable?`
* `boolean`
A boolean that indicates whether or not sign in attempts are transferable to the sign up flow. Defaults to `true`. When set to `false`, prevents opaque sign ups when a user attempts to sign in via OAuth with an email that doesn't exist.
***
* `verifyEmailAddressUrl?`
* `string | undefined | null`
The full URL or path to navigate to after requesting email verification.
***
* `verifyPhoneNumberUrl?`
* `string | undefined | null`
The full URL or path to navigate to after requesting phone verification.
---
title: "`` (deprecated)"
description: The component will navigate to
the Organization profile URL which has been configured in your application
instance. The behavior will be just like a server-side (3xx) redirect, and
will override the current location in the history stack.
sdk: nextjs, nuxt, react, react-router, remix, tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/redirect-to-organization-profile
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/control/redirect-to-organization-profile.mdx
---
> \[!WARNING]
> This feature is deprecated. Please use the redirectToOrganizationProfile() method instead.
The `` component will navigate to the Organization profile URL which has been configured in your application instance. The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.
## Example
```tsx {{ filename: 'app/routes/Home.tsx' }}
import { SignedIn, SignedOut, RedirectToOrganizationProfile } from '@clerk/react-router'
export default function Home() {
return (
<>
You need to sign in to view your Organization profile.
>
)
}
```
---
title: "``"
description: The Protect component protects content or even entire routes based
on authentication, and optionally, authorization. It only renders its children
when the current user is signed-in, and if performing authorization checks, if
the user has been granted a specific type of access control (Role, Permission,
Feature, or Plan).
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/protect
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/control/protect.mdx
---
The \ component protects content or even entire routes based on:
* authentication: whether the user is signed-in or not.
* authorization: whether the user has been granted a specific type of access control (Role, Permission, Feature, or Plan)
`` **always** performs authentication checks. To perform authorization checksAuthorization checks are checks you perform in your code to determine the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions or access certain content. Learn more about [authorization checks](/docs/guides/secure/authorization-checks)., you can pass different props, like `role`, `permission`, `feature`, or `plan`.
`` accepts a `fallback` prop that will be rendered if the user fails the authentication or authorization checks.
`` can be used both client-side and server-side (in Server Components).
> \[!CAUTION]
> This component only **visually hides** its children when the current user is not authorized. The contents of its children remain accessible via the browser's source code even if the user fails the authorization check. Do not use this component to hide sensitive information that should be completely inaccessible to unauthorized users. For truly sensitive data, perform authorization checksAuthorization checks are checks you perform in your code to determine the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions or access certain content. Learn more about [authorization checks](/docs/guides/secure/authorization-checks). on the server before sending the data to the client.
## Usage
### Authentication checks
`` always performs authentication checks. It will render its children if the user is signed-in, and its `fallback` prop if the user is signed-out.
```tsx {{ filename: 'app/routes/dashboard.tsx' }}
import { Protect } from '@clerk/react-router'
export default function DashboardPage() {
return (
Users that are signed-out can see this.}>
Users that are signed-in can see this.
)
}
```
### Authorization checks
To limit who is able to see the content that `` renders, you can pass **one** of the access control props: `permission`, `role`, `feature`, or `plan`. It's recommended to use **Permission-based** authorization over **Role-based** authorization, and **Feature-based** authorization over **Plan-based** authorization, as they are more flexible, easier to manage, and more secure.
If you do not pass any of the access control props, `` will render its children if the user is signed in, regardless of their Role or its Permissions.
For more complex authorization logic, pass conditional logic to the `condition` prop.
### Render content by Permissions
The following example demonstrates how to use the `` component to protect content by checking if the user has the `org:invoices:create` Permission.
```tsx {{ filename: 'app/routes/invoices.tsx' }}
import { Protect } from '@clerk/react-router'
export default function InvoicesPage() {
return (
You do not have the Permissions to create an invoice.}
>
Users with Permission org:invoices:create can see this.
)
}
```
### Render content by Role
While authorization by `permission` is **recommended**, for convenience, `` allows a `role` prop to be passed.
The following example demonstrates how to use the `` component to protect content by checking if the user has the `org:billing` Role.
```tsx {{ filename: 'app/routes/billing.tsx' }}
import { Protect } from '@clerk/react-router'
export default function BillingPage() {
return (
Only a member of the Billing department can access this content.}
>
Users with Role org:billing can see this.
)
}
```
### Render content by Plan
The following example demonstrates how to use `` to protect content by checking if the user has a Plan.
```tsx {{ filename: 'app/routes/bronze.tsx' }}
import { Protect } from '@clerk/react-router'
export default function BronzePage() {
return (
Sorry, only subscribers to the Bronze plan can access this content.}
>
Welcome, Bronze subscriber!
)
}
```
### Render content by Feature
The following example demonstrates how to use `` to protect content by checking if the user has a Feature.
```tsx {{ filename: 'app/routes/premium-access.tsx' }}
import { Protect } from '@clerk/react-router'
export default function PremiumAccessPage() {
return (
Sorry, only subscribers with the Premium Access feature can access this content.
}
>
Congratulations! You have access to the Premium Access feature.
)
}
```
### Render content conditionally
The following example uses ``'s `condition` prop to conditionally render its children if the user has the correct Role.
```tsx {{ filename: 'app/routes/settings.tsx' }}
import { Protect } from '@clerk/react-router'
export default function SettingsPage() {
return (
has({ role: 'org:admin' }) || has({ role: 'org:billing_manager' })}
fallback={
Only an Admin or Billing Manager can access this content.
}
>
The settings page.
)
}
```
## Properties
* `condition?`
* `has => boolean`
Optional conditional logic that renders the children if it returns `true`.
***
* `fallback?`
* `JSX`
Optional UI to show when a user doesn't have the correct type of access control to access the protected content.
***
* `feature?`
* `string`
Optional string corresponding to a [Feature](/docs/guides/billing/overview).
***
* `plan?`
* `string`
Optional string corresponding to a [Plan](/docs/guides/billing/overview).
***
* `permission?`
* `string`
Optional string corresponding to a [Permission](/docs/guides/organizations/roles-and-permissions) in the format `org::`
***
* `role?`
* `string`
Optional string corresponding to a [Role](/docs/guides/organizations/roles-and-permissions) in the format `org:`
***
* `treatPendingAsSignedOut?`
* `boolean`
A boolean that indicates whether to treat pending sessions as signed out. Defaults to `true`.
---
title: "``"
description: The component will navigate to the sign in URL
which has been configured in your application instance. The behavior will be
just like a server-side (3xx) redirect, and will override the current location
in the history stack.
sdk: chrome-extension, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/redirect-to-sign-in
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: chrome-extension,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,expo,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/control/redirect-to-sign-in.mdx
---
The `` component will navigate to the sign in URL which has been configured in your application instance. The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.
## Example
```tsx {{ filename: 'app/routes/home.tsx' }}
import { SignedIn, SignedOut, RedirectToSignIn, UserButton } from '@clerk/react-router'
export default function Home() {
return (
<>
>
)
}
```
---
title: "``"
description: The `` renders its children while Clerk is loading,
and is helpful for showing a custom loading state.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/clerk-loading
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/control/clerk-loading.mdx
---
The `` renders its children while Clerk is loading, and is helpful for showing a custom loading state.
## Example
It's not recommended to wrap the entire app in the `` component; instead, only wrap the components that need access to the `Clerk` object.
```tsx {{ filename: 'app/routes/example.tsx' }}
import { ClerkLoading, ClerkLoaded, ClerkDegraded, ClerkFailed } from '@clerk/react-router'
export default function Example() {
return (
<>
Clerk is loading...
Clerk has loaded (ready or degraded)
Clerk is experiencing issues. Please try again later.
Something went wrong with Clerk. Please contact support.
>
)
}
```
---
title: "`` (deprecated)"
description: The component will navigate to the
create Organization flow which has been configured in your application
instance. The behavior will be just like a server-side (3xx) redirect, and
will override the current location in the history stack.
sdk: nextjs, nuxt, react, react-router, remix, tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/redirect-to-create-organization
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/control/redirect-to-create-organization.mdx
---
> \[!WARNING]
> This feature is deprecated. Please use the redirectToCreateOrganization() method instead.
The `` component will navigate to the create Organization flow which has been configured in your application instance. The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.
## Example
```tsx {{ filename: 'app/routes/home.tsx' }}
import { SignedIn, SignedOut, RedirectToCreateOrganization } from '@clerk/react-router'
export default function Home() {
return (
<>
You need to sign in to create an Organization.
>
)
}
```
---
title: "``"
description: The component will navigate to the sign up URL
which has been configured in your application instance. The behavior will be
just like a server-side (3xx) redirect, and will override the current location
in the history stack.
sdk: chrome-extension, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/redirect-to-sign-up
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: chrome-extension,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,expo,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/control/redirect-to-sign-up.mdx
---
The `` component will navigate to the sign up URL which has been configured in your application instance. The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.
## Example
```tsx {{ filename: 'app/routes/home.tsx' }}
import { SignedIn, SignedOut, RedirectToSignUp, UserButton } from '@clerk/react-router'
export default function Home() {
return (
<>
>
)
}
```
---
title: "``"
description: The component will navigate to the tasks flow
which has been configured in your application instance when users have pending
session tasks. The behavior will be just like a server-side (3xx) redirect,
and will override the current location in the history stack.
sdk: chrome-extension, nextjs, nuxt, react, react-router, tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/redirect-to-tasks
lastUpdated: 2025-11-21T22:25:46.000Z
availableSdks: chrome-extension,nextjs,nuxt,react,react-router,tanstack-react-start,vue
notAvailableSdks: js-frontend,expo,android,ios,expressjs,fastify,remix,go,astro,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/control/redirect-to-tasks.mdx
---
The `` component will navigate to the tasks flow which has been configured in your application instance when users have pending session tasks**Session tasks** are requirements that users must fulfill in order to complete the authentication process, such as choosing an Organization.. The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.
The `` component is primarily intended for use in custom flowsA **custom flow** refers to a user interface built entirely from scratch using the Clerk API. Learn more about [custom flows](/docs/guides/development/custom-flows/overview).. If you're using prebuilt components, you typically won't need to use `` as these components manage task redirection internally. [See the guide on handling session tasks outside of prebuilt components](/docs/guides/configure/session-tasks#redirecting-to-tasks).
## Example
```tsx {{ filename: 'app/routes/home.tsx' }}
import { SignedOut, RedirectToTasks } from '@clerk/react-router'
export default function Home() {
return (
<>
>
)
}
```
---
title: "``"
description: Conditionally render content only when a user is signed in.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/signed-in
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/control/signed-in.mdx
---
## Overview
The `` component offers authentication checks as a cross-cutting concern. Any children components wrapped by a `` component will be rendered only if there's a user with an active session signed in your application.
> \[!CAUTION]
> This component only **visually hides** its children when the current user is not authenticated. The contents of its children remain accessible via the browser's source code even if the user fails the authentication check. Do not use this component to hide sensitive information that should be completely inaccessible to unauthorized users. For truly sensitive data, perform authorization checksAuthorization checks are checks you perform in your code to determine the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions or access certain content. Learn more about [authorization checks](/docs/guides/secure/authorization-checks). on the server before sending the data to the client.
## Example
```tsx {{ filename: 'app/routes/home.tsx' }}
import { SignedIn } from '@clerk/react-router'
export default function Home() {
return (
<>
You are signed in.
This content is always visible.
>
)
}
```
## Properties
* `treatPendingAsSignedOut?`
* `boolean`
A boolean that indicates whether to treat pending sessions as signed out. Defaults to `true`.
---
title: "`` (deprecated)"
description: The component will navigate to the user
profile URL which has been configured in your application instance. The
behavior will be just like a server-side (3xx) redirect, and will override the
current location in the history stack.
sdk: nextjs, nuxt, react, react-router, remix, tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/redirect-to-user-profile
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/control/redirect-to-user-profile.mdx
---
> \[!WARNING]
> This feature is deprecated. Please use the redirectToUserProfile() method instead.
The `` component will navigate to the Account Portal User Profile URL which has been configured in your application instance. The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.
To find your User Profile URL:
1. In the Clerk Dashboard, navigate to the [**Account Portal**](https://dashboard.clerk.com/~/account-portal) page.
2. Under **User profile**, select the **Visit** icon.
## Example
```tsx {{ filename: 'app/routes/home.tsx' }}
import { SignedIn, SignedOut, RedirectToUserProfile } from '@clerk/react-router'
export default function Home() {
return (
<>
You need to sign in to view your user profile.
>
)
}
```
---
title: "``"
description: Conditionally render content only when a user is signed out.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/control/signed-out
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/control/signed-out.mdx
---
The `` component offers authentication checks as a cross-cutting concern. Any child nodes wrapped by a `` component will be rendered only if there's no User signed in to your application.
## Example
```tsx {{ filename: 'app/routes/home.tsx' }}
import { SignedOut } from '@clerk/react-router'
export default function Home() {
return (
<>
You are signed out.
This content is always visible.
>
)
}
```
## Properties
* `treatPendingAsSignedOut?`
* `boolean`
A boolean that indicates whether to treat pending sessions as signed out. Defaults to `true`.
---
title: "`` component"
description: Clerk's component is used to render a
beautiful, full-featured Organization management UI that allows users to
manage their Organization profile and security settings.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/organization/organization-profile
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/organization/organization-profile.mdx
---

The `` component allows users to manage their Organization membership, security, and billing settings.
This component's **General** tab displays the Organization's information and the **Leave organization** button. Admins will be able to see the **Update profile** button, **Verified domains** section, and **Delete organization** button.
The **Members** tab shows the Organization's members along with their join dates and Roles. Admins will have the ability to invite a member, change a member's Role, or remove them from the Organization. Admins will have tabs within the **Members** tab to view the Organization's [invitations](/docs/guides/organizations/overview#organization-invitations) and [requests](/docs/guides/organizations/verified-domains#membership-requests).
The **Billing** tab displays the Plans and Features that are available to the Organization, as well as the user's billing information, such as their invoices and payment methods.
## Example
The `` component must be embedded using the [React Router Splat route](https://reactrouter.com/start/framework/routing#splats) in order for the routing to work.
```tsx {{ filename: 'app/routes/organization-profile.$.tsx' }}
import { OrganizationProfile } from '@clerk/react-router'
export default function OrganizationProfilePage() {
return
}
```
## Properties
The `` component accepts the following properties, all of which are **optional**:
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `afterLeaveOrganizationUrl`
* `string`
The full URL or path to navigate to after leaving an Organization.
***
* `customPages`
* `CustomPages[]`
An array of custom pages to add to the Organization profile. Only available for the JavaScript SDK. To add custom pages with React-based SDK's, see the [dedicated guide](/docs/guides/customizing-clerk/adding-items/organization-profile).
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash- and virtual-based routing. For example: `/organization-profile`.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
In addition, you also can add custom pages and links to the `` navigation sidenav. For more information, refer to the [Custom Pages](/docs/guides/customizing-clerk/adding-items/organization-profile) documentation.
---
title: "`` component"
description: Clerk's component is used to display
Organization related memberships, invitations, and suggestions for the user.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/organization/organization-list
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/organization/organization-list.mdx
---
{{ style: { maxWidth: '460px' } }}
The `` component displays Organization-related memberships and automatic [invitations](/docs/guides/organizations/verified-domains#automatic-invitations) and [suggestions](/docs/guides/organizations/verified-domains#automatic-suggestions) for the user.
## Example
```tsx {{ filename: 'app/routes/organizations.tsx' }}
import { OrganizationList } from '@clerk/react-router'
export default function OrganizationListPage() {
return (
`/organization/${org.slug}`}
afterSelectPersonalUrl={(user) => `/user/${user.id}`}
afterSelectOrganizationUrl={(org) => `/organization/${org.slug}`}
/>
)
}
```
## Properties
The `` component accepts the following properties, all of which are **optional**:
* `afterCreateOrganizationUrl`
* ((org: Organization) => string) | string
The full URL or path to navigate to after creating a new Organization.
***
* `afterSelectOrganizationUrl`
* ((org: Organization) => string) | string
The full URL or path to navigate to after selecting an Organization. Defaults to `undefined`.
***
* `afterSelectPersonalUrl`
* ((org: Organization) => string) | string
The full URL or path to navigate to after selecting the [Personal Account](/docs/guides/organizations/overview#allow-personal-accounts). Defaults to `undefined`.
***
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `hidePersonal`
* `boolean`
A boolean that controls whether `` will include the user's [Personal Account](/docs/guides/organizations/overview#allow-personal-accounts) in the Organization list. Setting this to `true` will hide the Personal Account option, and users will only be able to switch between Organizations. Defaults to `false`.
***
* `hideSlug`
* `boolean`
A boolean that controls whether the optional slug field in the Organization creation screen is hidden. Defaults to `false`.
***
* `skipInvitationScreen`
* `boolean | undefined`
A boolean that controls whether the screen for sending invitations after an Organization is created is hidden. When `undefined`, Clerk will automatically hide the screen if the number of max allowed members is equal to 1. Defaults to `false`.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
[org-ref]: /docs/reference/javascript/organization
---
title: "`` component"
description: Clerk's component is used to render an
Organization creation UI that allows users to create brand new Organizations
within your application.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/organization/create-organization
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/organization/create-organization.mdx
---
{{ style: { maxWidth: '492px' } }}
The `` component is used to render an Organization creation UI that allows users to create brand new Organizations in your application.
## Example
The following example includes a basic implementation of the `` component. You can use this as a starting point for your own implementation.
```tsx {{ filename: 'app/routes/create-organization.tsx' }}
import { CreateOrganization } from '@clerk/react-router'
export default function CreateOrganizationPage() {
return
}
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `afterCreateOrganizationUrl`
* `string`
Full URL or path to navigate to after creating a new organization.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash-based routing. For example: `/create-organization`.
***
* `skipInvitationScreen`
* `boolean`
Hides the screen for sending invitations after an Organization is created. When left undefined, Clerk will automatically hide the screen if the number of max allowed members is equal to 1
***
* `hideSlug`
* `boolean`
Hides the optional slug field in the Organization creation screen.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
---
title: "`` component"
description: Clerk's component is used to enable the
ability to switch between available Organizations the user may be part of in
your application.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/organization/organization-switcher
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/organization/organization-switcher.mdx
---
{{ style: { maxWidth: '436px' } }}
The `` component allows a user to switch between their joined Organizations. If [Personal Accounts are enabled](/docs/guides/organizations/overview#allow-personal-accounts), users can also switch to their Personal Account. This component is useful for applications that have a multi-tenant architecture, where users can be part of multiple Organizations. It handles all Organization-related flows, including full Organization management for admins. Learn more about [Organizations](/docs/guides/organizations/overview).
## Example
```tsx {{ filename: 'app/routes/organization-switcher.tsx' }}
import { OrganizationSwitcher } from '@clerk/react-router'
export default function OrganizationSwitcherPage() {
return
}
```
## Properties
The `` component accepts the following properties, all of which are **optional**:
* `afterCreateOrganizationUrl`
* `string`
The full URL or path to navigate to after creating a new Organization.
***
* `afterLeaveOrganizationUrl`
* `string`
The full URL or path to navigate to after the user leaves the currently Active OrganizationA user can be a member of multiple Organizations, but only one can be active at a time. The **Active Organization** determines which Organization-specific data the user can access and which Role and related Permissions they have within the Organization..
***
* `afterSelectOrganizationUrl`
* `string`
The full URL or path to navigate to after a successful Organization switch.
***
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `createOrganizationMode`
* `'modal' | 'navigation'`
A boolean that controls whether clicking the "Create organization" button will cause the \ component to open as a modal, or if the browser will navigate to the `createOrganizationUrl` where `` is mounted as a page. Defaults to: `'modal'`.
***
* `createOrganizationUrl`
* `string`
The full URL or path where the ``]createorg-ref component is mounted.
***
* `defaultOpen`
* `boolean`
A boolean that controls the default state of the `` component.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
***
* `hidePersonal`
* `boolean`
A boolean that controls whether `` will include the user's [Personal Account](/docs/guides/organizations/overview#allow-personal-accounts) in the Organization list. Setting this to `true` will hide the Personal Account option, and users will only be able to switch between Organizations. Defaults to `false`.
***
* `hideSlug`
* `boolean`
A boolean that controls whether the optional slug field in the Organization creation screen is hidden.
***
* `organizationProfileMode`
* `'modal' | 'navigation'`
A boolean that controls whether clicking the **Manage organization** button will cause the \ component to open as a modal, or if the browser will navigate to the `organizationProfileUrl` where `` is mounted as a page. Defaults to: `'modal'`.
***
* `organizationProfileProps`
* `object`
Specify options for the underlying \ component. For example: `{appearance: {...}}`
***
* `organizationProfileUrl`
* `string`
The full URL or path where the \ component is mounted.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
[createorg-ref]: /docs/reference/components/organization/create-organization
[orgprofile-ref]: /docs/reference/components/organization/organization-profile
---
title: "``"
description: The `` component is used to complete a
one-click, cryptographically-secure sign-in flow using MetaMask.
sdk: expo, nextjs, nuxt, react, react-router, remix, tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/unstyled/sign-in-with-metamask
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,chrome-extension,android,ios,expressjs,fastify,go,astro,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/unstyled/sign-in-with-metamask.mdx
---
The `` component is used to complete a one-click, cryptographically-secure sign-in flow using MetaMask.
## Usage
### Basic usage
```tsx {{ filename: 'app/routes/home.tsx' }}
import { SignInWithMetamaskButton } from '@clerk/react-router'
export default function Home() {
return
}
```
### Custom usage
In some cases, you will want to use your own button, or button text. You can do that by wrapping your button in the `` component.
```tsx {{ filename: 'app/routes/home.tsx' }}
import { SignInWithMetamaskButton } from '@clerk/react-router'
export default function Home() {
return (
Custom sign in button
)
}
```
---
title: "``"
description: The `` component is a button that signs a user out.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/unstyled/sign-out-button
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/unstyled/sign-out-button.mdx
---
The `` component is a button that signs a user out. By default, it is a `` tag that says **Sign Out**, but it is completely customizable by passing children.
## Usage
### Basic usage
```tsx {{ filename: 'app/routes/home.tsx' }}
import { SignOutButton } from '@clerk/react-router'
export default function Home() {
return
}
```
### Custom usage
You can create a custom button by wrapping your own button, or button text, in the `` component.
```tsx {{ filename: 'app/routes/home.tsx' }}
import { SignOutButton } from '@clerk/react-router'
export default function Home() {
return (
Custom sign out button
)
}
```
### Multi-session usage
#### Sign out of all sessions
Clicking the `` component signs the user out of all sessions. This is the default behavior.
#### Sign out of a specific session
You can sign out of a specific session by passing in a `sessionId` to the `sessionId` prop. This is useful for signing a single account out of a [multi-session application](/docs/guides/secure/session-options#multi-session-applications).
In the following example, the `sessionId` is retrieved from the useAuth() hook. If the user is not signed in, the `sessionId` will be `null`, and the user is shown the \ component. If the user is signed in, the user is shown the `` component, which when clicked, signs the user out of that specific session.
```tsx {{ filename: 'app/routes/home.tsx' }}
import { SignInButton, SignOutButton, useAuth } from '@clerk/react-router'
export default function Home() {
const { sessionId } = useAuth()
if (!sessionId) {
return
}
return
}
```
## Properties
* `redirectUrl?`
* `string`
The full URL or path to navigate after successful sign-out.
***
* `sessionId?`
* `string`
The ID of a specific session to sign out of. Useful for [multi-session applications](/docs/guides/secure/session-options#multi-session-applications).
***
* `children?`
* `React.ReactNode`
Children you want to wrap the `` in.
---
title: "``"
description: The component is a button that links to the sign-in
page or displays the sign-in modal.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/unstyled/sign-in-button
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/unstyled/sign-in-button.mdx
---
The `` component is a button that, by default, links to your app's sign-in page. Your sign-in page will be hosted by Clerk using the [Account Portal](/docs/guides/customizing-clerk/account-portal) unless you have set up a dedicated sign-in page.
## Usage
### Basic usage
```tsx {{ filename: 'app/routes/home.tsx' }}
import { SignInButton } from '@clerk/react-router'
export default function Home() {
return
}
```
### Custom usage
You can create a custom button by wrapping your own button, or button text, in the `` component.
```tsx {{ filename: 'app/routes/home.tsx' }}
import { SignInButton } from '@clerk/react-router'
export default function Home() {
return (
Custom sign in button
)
}
```
## Properties
* `forceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs in. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `fallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `oauthFlow`
* `"redirect" | "popup" | "auto"`
Determines how OAuth authentication is performed. Accepts the following properties:
* `"redirect"`: Redirect to the OAuth provider on the current page.
* `"popup"`: Open a popup window.
* `"auto"`: Choose the best method based on whether the current domain typically requires the `"popup"` flow to correctly perform authentication.
Defaults to `"auto"`.
***
* `signUpForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs up. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signUpFallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `mode?`
* `'redirect' | 'modal'`
Determines what happens when a user clicks on the ``. Setting this to `'redirect'` will redirect the user to the sign-in route. Setting this to `'modal'` will open a modal on the current route. Defaults to `'redirect'`.
***
* `children?`
* `React.ReactNode`
Children you want to wrap the `` in.
***
* `initialValues`
* SignInInitialValues
The values used to prefill the sign-in fields with.
---
title: "``"
description: The component is a button that links to the sign-up
page or displays the sign-up modal.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/unstyled/sign-up-button
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/unstyled/sign-up-button.mdx
---
The `` component is a button that, by default, links to your app's sign-up page. Your sign-up page will be hosted by Clerk using the [Account Portal](/docs/guides/customizing-clerk/account-portal) unless you have set up a dedicated sign-up page.
## Usage
### Basic usage
```tsx {{ filename: 'app/routes/home.tsx' }}
import { SignUpButton } from '@clerk/react-router'
export default function Home() {
return
}
```
### Custom usage
You can create a custom button by wrapping your own button, or button text, in the `` component.
```tsx {{ filename: 'app/routes/home.tsx' }}
import { SignUpButton } from '@clerk/react-router'
export default function Home() {
return (
Custom sign up button
)
}
```
## Properties
* `forceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs up. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `fallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs up, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `oauthFlow`
* `"redirect" | "popup" | "auto"`
Determines how OAuth authentication is performed. Accepts the following properties:
* `"redirect"`: Redirect to the OAuth provider on the current page.
* `"popup"`: Open a popup window.
* `"auto"`: Choose the best method based on whether the current domain typically requires the `"popup"` flow to correctly perform authentication.
Defaults to `"auto"`.
***
* `signInForceRedirectUrl?`
* `string`
If provided, this URL will always be redirected to after the user signs in. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `signInFallbackRedirectUrl?`
* `string`
The fallback URL to redirect to after the user signs in, if there's no `redirect_url` in the path already. Defaults to `/`. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `mode?`
* `'redirect' | 'modal'`
Determines what happens when a user clicks on the ``. Setting this to `'redirect'` will redirect the user to the sign-up route. Setting this to `'modal'` will open a modal on the current route. Defaults to `'redirect'`
***
* `children?`
* `React.ReactNode`
Children you want to wrap the `` in.
***
* `initialValues`
* SignUpInitialValues
The values used to prefill the sign-up fields with.
***
* `unsafeMetadata`
* SignUpUnsafeMetadata
Metadata that can be read and set from the frontend and the backend. Once the sign-up is complete, the value of this field will be automatically copied to the created user's unsafe metadata (`User.unsafeMetadata`). One common use case is to collect custom information about the user during the sign-up process and store it in this property. Read more about [unsafe metadata](/docs/guides/users/extending#unsafe-metadata).
---
title: "`` component"
description: Clerk's component is used to render the familiar
user button UI popularized by Google.
search:
rank: 1
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/user/user-button
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/user/user-button.mdx
---
{{ style: { maxWidth: '436px' } }}
The `` component renders the familiar user button UI popularized by Google. When selected, it opens a dropdown menu with options to manage account settings and sign out. The "Manage account" option launches the \ component, providing access to profile and security settings.
For users that have [multi-session](/docs/guides/secure/session-options#multi-session-applications) enabled, the `` also allows users to sign into multiple accounts at once and instantly switch between them without the need for a full page reload. Learn more [here](/docs/guides/secure/session-options#multi-session-applications).
## Example
In the following example, `` is mounted inside a header component, which is a common pattern on many websites and applications. When the user is signed in, they will see their avatar and be able to open the popup menu.
```tsx {{ filename: 'app/routes/home.tsx' }}
import { SignedIn, UserButton, SignInButton, SignedOut } from '@clerk/react-router'
export default function Home() {
return (
)
}
```
## Properties
The `` component accepts the following properties, all of which are **optional**:
* `afterMultiSessionSingleSignOutUrl` (deprecated)
* `string`
**Deprecated. Move `afterMultiSessionSingleSignOutUrl` to \.** The full URL or path to navigate to after signing out from a currently active account in a multi-session app.
***
* `afterSignOutUrl` (deprecated)
* `string`
**Deprecated. Move `afterSignOutUrl` to \.** The full URL or path to navigate to after a successful sign-out.
***
* `afterSwitchSessionUrl`
* `string`
The full URL or path to navigate to after a successful account change in a multi-session app.
***
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `defaultOpen`
* `boolean`
Controls whether the `` should open by default during the first render.
***
* `showName`
* `boolean`
Controls if the user name is displayed next to the user image button.
***
* `signInUrl`
* `string`
The full URL or path to navigate to when the **Add another account** button is clicked. It's recommended to use [the environment variable](/docs/guides/development/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
***
* `userProfileMode`
* `'modal' | 'navigation'`
Controls whether selecting the **Manage your account** button will cause the \ component to open as a modal, or if the browser will navigate to the `userProfileUrl` where `` is mounted as a page. Defaults to: `'modal'`.
***
* `userProfileProps`
* `object`
Specify options for the underlying \ component. For example: `{additionalOAuthScopes: {google: ['foo', 'bar'], github: ['qux']}}`.
***
* `userProfileUrl`
* `string`
The full URL or path leading to the user management interface.
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
You can also [add custom actions and links to the `` menu](/docs/guides/customizing-clerk/adding-items/user-button).
---
title: "`` component"
description: Clerk's component is used to render a beautiful,
full-featured account management UI that allows users to manage their profile
and security settings.
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/user/user-profile
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/user/user-profile.mdx
---
{{ style: { maxWidth: '100%' } }}
The `` component is used to render a beautiful, full-featured account management UI that allows users to manage their profile, security, and billing settings.
## Example
The `` component must be embedded using the [React Router Splat route](https://reactrouter.com/start/framework/routing#splats) in order for the routing to work.
```tsx {{ filename: 'app/routes/user-profile.$.tsx' }}
import { UserProfile } from '@clerk/react-router'
export default function UserProfilePage() {
return
}
```
## Properties
All props are optional.
* `appearance`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `routing`
* `'hash' | 'path'`
The [routing](/docs/guides/how-clerk-works/routing) strategy for your pages. Defaults to `'path'` for frameworks that handle routing, such as Next.js and Remix. Defaults to `hash` for all other SDK's, such as React.
***
* `path`
* `string`
The path where the component is mounted on when `routing` is set to `path`. It is ignored in hash-based routing. For example: `/user-profile`.
***
* `additionalOAuthScopes`
* `object`
Specify additional scopes per OAuth provider that your users would like to provide if not already approved. For example: `{google: ['foo', 'bar'], github: ['qux']}`.
***
* `customPages`
* CustomPage\[]
An array of custom pages to add to the user profile. Only available for the JavaScript SDK. To add custom pages with React-based SDK's, see the [dedicated guide](/docs/guides/customizing-clerk/adding-items/user-profile).
***
* `fallback?`
* `ReactNode`
An optional element to be rendered while the component is mounting.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
In addition, you also can add custom pages and links to the `` navigation sidenav. For more information, refer to the [Custom Pages documentation](/docs/guides/customizing-clerk/adding-items/user-profile).
---
title: "`` component"
description: Clerk's component is used to render the familiar
user avatar on its own.
search:
rank: 1
sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix,
tanstack-react-start, vue, js-frontend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/user/user-avatar
lastUpdated: 2025-11-21T23:29:30.000Z
availableSdks: astro,chrome-extension,expo,nextjs,nuxt,react,react-router,remix,tanstack-react-start,vue,js-frontend
notAvailableSdks: android,ios,expressjs,fastify,go,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/components/user/user-avatar.mdx
---

The `` component renders the authenticated user's avatar on its own, a common UI element found across many websites and applications.
## Example
In the following example, `` is mounted inside a header component, which is a common pattern on many websites and applications. When the user is signed in, they will see their avatar.
```tsx {{ filename: 'app/routes/home.tsx' }}
import { SignedIn, UserAvatar, SignInButton, SignedOut } from '@clerk/react-router'
export default function Home() {
return (
)
}
```
## Properties
The `` component accepts the following properties, all of which are **optional**:
* `rounded?`
* `boolean`
Determines whether the user avatar is displayed with rounded corners.
***
* `appearance?`
* [Appearance](/docs/guides/customizing-clerk/appearance-prop/overview) | undefined
Optional object to style your components. Will only affect Clerk components and not [Account Portal](/docs/guides/customizing-clerk/account-portal) pages.
***
* `fallback?`
* `ReactNode`
Optional element to be rendered while the component is mounting.
## Customization
To learn about how to customize Clerk components, see the [customization documentation](/docs/guides/customizing-clerk/appearance-prop/overview).
---
title: Hooks Reference
description: A list of Clerk's comprehensive suite of hooks for managing
authentication, sessions, sign-in and sign-up flows, Organizations, and
reverification.
sdk: astro, chrome-extension, expo, nextjs, react, react-router, remix,
tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/overview
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: astro,chrome-extension,expo,nextjs,react,react-router,remix,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,nuxt,vue,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/hooks/overview.mdx
---
Clerk offers a comprehensive suite of hooks that expose low-level access to authentication, session management, and multi-tenancy. With Clerk hooks, you can access and manage user data, handle sign-in and sign-up flows, control session management, and implement advanced flows like session reverification for sensitive actions. By using these hooks, you can extend or replace Clerk's built-in components and customize how authentication behaves in your application.
## Hooks
* useUser()
* useClerk()
* useAuth()
* useSignIn()
* useSignUp()
* useSession()
* useSessionList()
* useOrganization()
* useOrganizationList()
* useReverification()
* useCheckout()
* usePaymentElement()
* usePaymentMethods()
* usePlans()
* useSubscription()
* useStatements()
* usePaymentAttempts()
* [Join our Discord](https://clerk.com/discord "Join Discord")
* Join our official Discord server to chat with us directly and become a part of the Clerk community.
* {}
***
* [Need help?](/support "Get help")
* Contact us through Discord, Twitter, or email to receive answers to your questions and learn more about Clerk.
* {}
---
title: useAuth()
description: Access and manage authentication state in your application with
Clerk's useAuth() hook.
sdk: astro, chrome-extension, expo, nextjs, react, react-router,
tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-auth
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: astro,chrome-extension,expo,nextjs,react,react-router,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,remix,go,nuxt,vue,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/hooks/use-auth.mdx
---
The `useAuth()` hook provides access to the current user's authentication state and methods to manage the active session.
> \[!NOTE]
> To access auth data server-side, see the Auth object reference doc.
## Parameters
| Parameter | Type | Description |
| ---------------------------- | -------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `initialAuthStateOrOptions?` | null \| Record\ \| \{ treatPendingAsSignedOut?: boolean; \} | An object containing the initial authentication state or options for the `useAuth()` hook. If not provided, the hook will attempt to derive the state from the context. `treatPendingAsSignedOut` is a boolean that indicates whether pending sessions are considered as signed out or not. Defaults to `true`. |
## Returns
There are multiple variants of this type available which you can select by clicking on one of the tabs.
| Name | Type | Description |
| ------ | ------ | ------ |
| `actor` | `undefined` | The JWT actor for the session. Holds identifier for the user that is impersonating the current user. Read more about [impersonation](/docs/guides/users/impersonation). |
| `getToken()` | (options?: GetTokenOptions) => Promise\ | A function that retrieves the current user's session token or a custom JWT template. Returns a promise that resolves to the token. See the reference doc. |
| `has` | `undefined` | A function that checks if the user has specific permissions or roles. See the reference doc. |
| `isLoaded` | `false` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `undefined` | A boolean that indicates whether a user is currently signed in. |
| `orgId` | `undefined` | The ID of the user's active organization. |
| `orgRole` | `undefined` | The current user's role in their active organization. |
| `orgSlug` | `undefined` | The URL-friendly identifier of the user's active organization. |
| `sessionClaims` | `undefined` | The current user's [session claims](/docs/guides/sessions/session-tokens). |
| `sessionId` | `undefined` | The ID for the current session. |
| `signOut()` | \{ (options?: SignOutOptions): Promise\; (signOutCallback?: SignOutCallback, options?: SignOutOptions): Promise\; \} | A function that signs out the current user. Returns a promise that resolves when complete. See the reference doc. |
| `userId` | `undefined` | The ID of the current user. |
| Name | Type | Description |
| ------ | ------ | ------ |
| `actor` | `null` | The JWT actor for the session. Holds identifier for the user that is impersonating the current user. Read more about [impersonation](/docs/guides/users/impersonation). |
| `getToken()` | (options?: GetTokenOptions) => Promise\ | A function that retrieves the current user's session token or a custom JWT template. Returns a promise that resolves to the token. See the reference doc. |
| `has()` | (params: CheckAuthorizationParamsWithCustomPermissions) => false | A function that checks if the user has specific permissions or roles. See the reference doc. |
| `isLoaded` | `true` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `false` | A boolean that indicates whether a user is currently signed in. |
| `orgId` | `null` | The ID of the user's active organization. |
| `orgRole` | `null` | The current user's role in their active organization. |
| `orgSlug` | `null` | The URL-friendly identifier of the user's active organization. |
| `sessionClaims` | `null` | The current user's [session claims](/docs/guides/sessions/session-tokens). |
| `sessionId` | `null` | The ID for the current session. |
| `signOut()` | \{ (options?: SignOutOptions): Promise\; (signOutCallback?: SignOutCallback, options?: SignOutOptions): Promise\; \} | A function that signs out the current user. Returns a promise that resolves when complete. See the reference doc. |
| `userId` | `null` | The ID of the current user. |
| Name | Type | Description |
| ------ | ------ | ------ |
| `actor` | null \| \{ \[x: string]: unknown; sub: string; \} | The JWT actor for the session. Holds identifier for the user that is impersonating the current user. Read more about [impersonation](/docs/guides/users/impersonation). |
| `getToken()` | (options?: GetTokenOptions) => Promise\ | A function that retrieves the current user's session token or a custom JWT template. Returns a promise that resolves to the token. See the reference doc. |
| `has()` | (isAuthorizedParams: CheckAuthorizationParamsWithCustomPermissions) => boolean | A function that checks if the user has specific permissions or roles. See the reference doc. |
| `isLoaded` | `true` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `true` | A boolean that indicates whether a user is currently signed in. |
| `orgId` | `null` | The ID of the user's active organization. |
| `orgRole` | `null` | The current user's role in their active organization. |
| `orgSlug` | `null` | The URL-friendly identifier of the user's active organization. |
| `sessionClaims` | `JwtPayload` | The current user's [session claims](/docs/guides/sessions/session-tokens). |
| `sessionId` | `string` | The ID for the current session. |
| `signOut()` | \{ (options?: SignOutOptions): Promise\; (signOutCallback?: SignOutCallback, options?: SignOutOptions): Promise\; \} | A function that signs out the current user. Returns a promise that resolves when complete. See the reference doc. |
| `userId` | `string` | The ID of the current user. |
| Name | Type | Description |
| ------ | ------ | ------ |
| `actor` | null \| \{ \[x: string]: unknown; sub: string; \} | The JWT actor for the session. Holds identifier for the user that is impersonating the current user. Read more about [impersonation](/docs/guides/users/impersonation). |
| `getToken()` | (options?: GetTokenOptions) => Promise\ | A function that retrieves the current user's session token or a custom JWT template. Returns a promise that resolves to the token. See the reference doc. |
| `has()` | (isAuthorizedParams: CheckAuthorizationParamsWithCustomPermissions) => boolean | A function that checks if the user has specific permissions or roles. See the reference doc. |
| `isLoaded` | `true` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `true` | A boolean that indicates whether a user is currently signed in. |
| `orgId` | `string` | The ID of the user's active organization. |
| `orgRole` | `string` | The current user's role in their active organization. |
| `orgSlug` | null \| string | The URL-friendly identifier of the user's active organization. |
| `sessionClaims` | `JwtPayload` | The current user's [session claims](/docs/guides/sessions/session-tokens). |
| `sessionId` | `string` | The ID for the current session. |
| `signOut()` | \{ (options?: SignOutOptions): Promise\; (signOutCallback?: SignOutCallback, options?: SignOutOptions): Promise\; \} | A function that signs out the current user. Returns a promise that resolves when complete. See the reference doc. |
| `userId` | `string` | The ID of the current user. |
## Example
The following example demonstrates how to use the `useAuth()` hook to access the current auth state, like whether the user is signed in or not. It also includes a basic example for using the `getToken()` method to retrieve a session token for fetching data from an external resource.
```tsx {{ filename: 'app/routes/home.tsx' }}
import { useAuth } from '@clerk/react-router'
export default function Home() {
const { userId, sessionId, getToken, isLoaded, isSignedIn } = useAuth()
const fetchExternalData = async () => {
const token = await getToken()
// Fetch data from an external API
const response = await fetch('https://api.example.com/data', {
headers: {
Authorization: `Bearer ${token}`,
},
})
return response.json()
}
// Handle loading state
if (!isLoaded) return
Loading...
// Protect the page from unauthenticated users
if (!isSignedIn) return
Sign in to view this page
return (
Hello, {userId}! Your current active session is {sessionId}.
Fetch Data
)
}
```
---
title: useClerk()
description: Access and manage the Clerk object in your React application with
Clerk's useClerk() hook.
sdk: chrome-extension, expo, nextjs, react, react-router, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-clerk
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: chrome-extension,expo,nextjs,react,react-router,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,remix,go,astro,nuxt,vue,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/hooks/use-clerk.mdx
---
> \[!WARNING]
> This hook should only be used for advanced use cases, such as building a completely custom OAuth flow or as an escape hatch to access to the `Clerk` object.
The `useClerk()` hook provides access to the Clerk object, allowing you to build alternatives to any Clerk Component.
## Returns
Clerk — The `useClerk()` hook returns the `Clerk` object, which includes all the methods and properties listed in the Clerk reference.
## Example
The following example uses the `useClerk()` hook to access the `clerk` object. The `clerk` object is used to call the openSignIn() method to open the sign-in modal.
```tsx {{ filename: 'app/routes/home.tsx' }}
import { useClerk } from '@clerk/react-router'
export default function Home() {
const clerk = useClerk()
return clerk.openSignIn({})}>Sign in
}
```
---
title: useSessionList()
description: Access and manage the current user's session list in your React
application with Clerk's useSessionList() hook.
sdk: chrome-extension, expo, nextjs, react, react-router, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-session-list
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: chrome-extension,expo,nextjs,react,react-router,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,remix,go,astro,nuxt,vue,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/hooks/use-session-list.mdx
---
The `useSessionList()` hook returns an array of Session objects that have been registered on the client device.
## Returns
There are multiple variants of this type available which you can select by clicking on one of the tabs.
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `false` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `sessions` | `undefined` | A list of sessions that have been registered on the client device. |
| `setActive` | `undefined` | A function that sets the active session and/or organization. See the reference doc. |
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `true` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `sessions` | SessionResource\[] | A list of sessions that have been registered on the client device. |
| `setActive()` | (setActiveParams: SetActiveParams) => Promise\ | A function that sets the active session and/or organization. See the reference doc. |
## Example
### Get a list of sessions
The following example uses `useSessionList()` to get a list of sessions that have been registered on the client device. The `sessions` property is used to show the number of times the user has visited the page.
```tsx {{ filename: 'app/routes/home.tsx' }}
import { useSessionList } from '@clerk/react-router'
export default function Home() {
const { isLoaded, sessions } = useSessionList()
// Handle loading state
if (!isLoaded) return
Loading...
return (
Welcome back. You've been here {sessions.length} times before.
)
}
```
---
title: useOrganization()
description: Access and manage the currently active Organization in your React
application with Clerk's useOrganization() hook.
search:
rank: 1
sdk: chrome-extension, expo, nextjs, react, react-router, remix,
tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-organization
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: chrome-extension,expo,nextjs,react,react-router,remix,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/hooks/use-organization.mdx
---
The `useOrganization()` hook retrieves attributes of the currently Active OrganizationA user can be a member of multiple Organizations, but only one can be active at a time. The **Active Organization** determines which Organization-specific data the user can access and which Role and related Permissions they have within the Organization..
## Parameters
`useOrganization()` accepts a single object with the following optional properties:
| Property | Type | Description |
| ----------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `domains?` | true \| \{ initialPage?: number; pageSize?: number; \} & \{ enrollmentMode?: "manual\_invitation" \| "automatic\_invitation" \| "automatic\_suggestion"; \} & \{ infinite?: boolean; keepPreviousData?: boolean; \} | If set to `true`, all default properties will be used. Otherwise, accepts an object with the following optional properties:
`enrollmentMode`: A string that filters the domains by the provided [enrollment mode](/docs/guides/organizations/verified-domains#enrollment-mode).
Any of the properties described in Shared properties.
|
| `invitations?` | true \| \{ initialPage?: number; pageSize?: number; \} & \{ status?: ("expired" \| "pending" \| "accepted" \| "revoked")\[]; \} & \{ infinite?: boolean; keepPreviousData?: boolean; \} | If set to `true`, all default properties will be used. Otherwise, accepts an object with the following optional properties:
`status`: A string that filters the invitations by the provided status.
Any of the properties described in Shared properties.
|
| `membershipRequests?` | true \| \{ initialPage?: number; pageSize?: number; \} & \{ status?: "expired" \| "pending" \| "accepted" \| "revoked"; \} & \{ infinite?: boolean; keepPreviousData?: boolean; \} | If set to `true`, all default properties will be used. Otherwise, accepts an object with the following optional properties:
`status`: A string that filters the membership requests by the provided status.
Any of the properties described in Shared properties.
|
| `memberships?` | true \| \{ initialPage?: number; pageSize?: number; \} & \{ query?: string; role?: string\[]; \} & \{ infinite?: boolean; keepPreviousData?: boolean; \} | If set to `true`, all default properties will be used. Otherwise, accepts an object with the following optional properties:
`role`: An array of OrganizationCustomRoleKey.
`query`: A string that filters the memberships by the provided string.
Any of the properties described in Shared properties.
|
> \[!WARNING]
> By default, the `memberships`, `invitations`, `membershipRequests`, and `domains` attributes aren't populated. To fetch and paginate the data, you must pass `true` or an object with the desired properties.
### Shared properties
Optional properties that are shared across the `invitations`, `membershipRequests`, `memberships`, and `domains` properties.
| Property | Type | Description |
| --------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `initialPage?` | `number` | A number that specifies which page to fetch. For example, if `initialPage` is set to 10, it will skip the first 9 pages and fetch the 10th page. Defaults to `1`. |
| `pageSize?` | `number` | A number that specifies the maximum number of results to return per page. Defaults to `10`. |
| Name | Type | Description |
| ------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `infinite?` | `boolean` | If `true`, newly fetched data will be appended to the existing list rather than replacing it. Useful for implementing infinite scroll functionality. Defaults to `false`. |
| `keepPreviousData?` | `boolean` | If `true`, the previous data will be kept in the cache until new data is fetched. Defaults to `false`. |
> \[!NOTE]
> These attributes are updating automatically and will re-render their respective components whenever you set a different Organization using the setActive(\{ organization }) method or update any of the memberships or invitations. No need for you to manage updating anything manually.
## Returns
| Property | Type | Description |
| ---------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `domains` | null \| PaginatedResourcesWithDefault\<OrganizationDomainResource\> \| PaginatedResources\<OrganizationDomainResource, T\["membershipRequests"] *extends* \{ infinite: true; \} ? true : false\> | Includes a paginated list of the organization's domains. |
| `invitations` | null \| PaginatedResourcesWithDefault\<OrganizationInvitationResource\> \| PaginatedResources\<OrganizationInvitationResource, T\["invitations"] *extends* \{ infinite: true; \} ? true : false\> | Includes a paginated list of the organization's invitations. |
| `isLoaded` | `boolean` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `membership` | undefined \| null \| OrganizationMembershipResource | The current organization membership. |
| `membershipRequests` | null \| PaginatedResourcesWithDefault\<OrganizationMembershipRequestResource\> \| PaginatedResources\<OrganizationMembershipRequestResource, T\["membershipRequests"] *extends* \{ infinite: true; \} ? true : false\> | Includes a paginated list of the organization's membership requests. |
| `memberships` | null \| PaginatedResourcesWithDefault\<OrganizationMembershipResource\> \| PaginatedResources\<OrganizationMembershipResource, T\["memberships"] *extends* \{ infinite: true; \} ? true : false\> | Includes a paginated list of the organization's memberships. |
| `organization` | undefined \| null \| OrganizationResource | The currently active organization. |
### `PaginatedResources`
| Property | Type | Description |
| ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `count` | `number` | The total count of data that exist remotely. |
| `data` | T\[] | An array that contains the fetched data. For example, for the `memberships` attribute, data will be an array of OrganizationMembership objects. |
| `error` | null \| ClerkAPIResponseError | Clerk's API response error object. |
| `fetchNext` | () => void | A function that triggers the next page to be loaded. This is the same as `fetchPage(page => Math.min(pageCount, page + 1))`. |
| `fetchPage` | `ValueOrSetter`\<`number`\> | A function that triggers a specific page to be loaded. |
| `fetchPrevious` | () => void | A function that triggers the previous page to be loaded. This is the same as `fetchPage(page => Math.max(0, page - 1))`. |
| `hasNextPage` | `boolean` | A boolean that indicates if there are available pages to be fetched. |
| `hasPreviousPage` | `boolean` | A boolean that indicates if there are available pages to be fetched. |
| `isError` | `boolean` | A boolean that indicates the request failed. |
| `isFetching` | `boolean` | A boolean that is `true` if there is an ongoing request or a revalidation. |
| `isLoading` | `boolean` | A boolean that is `true` if there is an ongoing request and there is no fetched data. |
| `page` | `number` | The current page. |
| `pageCount` | `number` | The total amount of pages. It is calculated based on `count`, `initialPage`, and `pageSize`. |
| `revalidate` | () => Promise\ | A function that triggers a revalidation of the current page. |
| `setData` | `Infinite` *extends* `true` ? `CacheSetter`\<(undefined \| ClerkPaginatedResponse\)\[]\> : `CacheSetter`\<undefined \| ClerkPaginatedResponse\\> | A function that allows you to set the data manually. |
To see the different Organization features integrated into one application, take a look at our [Organizations demo repository](https://github.com/clerk/organizations-demo).
## Examples
### Expand and paginate attributes
To keep network usage to a minimum, developers are required to opt-in by specifying which resource they need to fetch and paginate through. By default, the `memberships`, `invitations`, `membershipRequests`, and `domains` attributes are not populated. You must pass `true` or an object with the desired properties to fetch and paginate the data.
```jsx
// invitations.data will never be populated.
const { invitations } = useOrganization()
// Use default values to fetch invitations, such as initialPage = 1 and pageSize = 10
const { invitations } = useOrganization({
invitations: true,
})
// Pass your own values to fetch invitations
const { invitations } = useOrganization({
invitations: {
pageSize: 20,
initialPage: 2, // skips the first page
},
})
// Aggregate pages in order to render an infinite list
const { invitations } = useOrganization({
invitations: {
infinite: true,
},
})
```
### Infinite pagination
The following example demonstrates how to use the `infinite` property to fetch and append new data to the existing list. The `memberships` attribute will be populated with the first page of the Organization's memberships. When the "Load more" button is clicked, the `fetchNext` helper function will be called to append the next page of memberships to the list.
```tsx {{ filename: 'app/routes/members.tsx' }}
import { useOrganization } from '@clerk/react-router'
export default function MemberListPage() {
const { memberships } = useOrganization({
memberships: {
infinite: true, // Append new data to the existing list
keepPreviousData: true, // Persist the cached data until the new data has been fetched
},
})
// Handle loading state
if (!memberships) return
)
}
```
### Simple pagination
The following example demonstrates how to use the `fetchPrevious` and `fetchNext` helper functions to paginate through the data. The `memberships` attribute will be populated with the first page of the Organization's memberships. When the "Previous page" or "Next page" button is clicked, the `fetchPrevious` or `fetchNext` helper function will be called to fetch the previous or next page of memberships.
Notice the difference between this example's pagination and the infinite pagination example above.
```tsx {{ filename: 'app/routes/members-paginated.tsx' }}
import { useOrganization } from '@clerk/react-router'
export default function MemberListPage() {
const { memberships } = useOrganization({
memberships: {
keepPreviousData: true, // Persist the cached data until the new data has been fetched
},
})
// Handle loading state
if (!memberships) return
)
}
```
## Related guides
* [Update an Organization](/docs/guides/development/custom-flows/organizations/update-organizations)
* Use Clerk's API to build a custom flow for updating an Organization
***
* [Manage Roles in an Organization](/docs/guides/development/custom-flows/organizations/manage-roles)
* Use Clerk's API to build a custom flow for managing Roles in an Organization
***
* [Manage an Organization's membership requests](/docs/guides/development/custom-flows/organizations/manage-membership-requests)
* Use Clerk's API to build a custom flow for managing an Organization's membership requests
***
* [Manage a user's Organization invitations](/docs/guides/development/custom-flows/organizations/manage-user-org-invitations)
* Use Clerk's API to build a custom flow for managing user's Organization invitations
---
title: useReverification()
description: Clerk's useReverification() hook enhances a fetcher function to
handle a session's reverification flow.
sdk: chrome-extension, expo, nextjs, react, react-router, remix,
tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-reverification
lastUpdated: 2025-11-21T22:25:46.000Z
availableSdks: chrome-extension,expo,nextjs,react,react-router,remix,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/hooks/use-reverification.mdx
---
> \[!WARNING]
>
> Depending on the SDK you're using, this feature requires `@clerk/nextjs@6.12.7` or later, `@clerk/clerk-react@5.25.1` or later, `@clerk/clerk-js@5.57.1` or later and `@clerk/clerk-sdk-ruby@3.3.0` or later.
Reverification allows you to prompt a user to verify their credentials before performing sensitive actions, even if they're already authenticated. For example, in a banking application, transferring money is considered a "sensitive action." Reverification can be used to confirm the user's identity.
The `useReverification()` hook is used to handle a session's reverification flow. If a request requires reverification, a modal will display, prompting the user to verify their credentials. Upon successful verification, the original request will automatically retry. If you'd like to build a custom UI, you can use the onNeedsReverification option.
When using reverification, a user's credentials are valid for 10 minutes. Once stale, a user will need to reverify their credentials. This time duration can be customized by using the `has()` helper on the server-side. See the [guide on reverification](/docs/guides/secure/reverification) for more information.
## Parameters
| Parameter | Type | Description |
| ---------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `fetcher` | `Fetcher extends (...args: any[]) => Promise` | A function that returns a promise. |
| `options?` | `Options` | Optional configuration object extending UseReverificationOptions. |
### `UseReverificationOptions`
The optional options object.
| Property | Type | Description |
| ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `onNeedsReverification?` | (properties: NeedsReverificationParameters) => void | Handler for the reverification process. Opts out of using the default UI. Use this to build a custom UI. |
### `NeedsReverificationParameters`
| Property | Type | Description |
| -------------------------------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| `cancel` | () => void | Marks the reverification process as cancelled and rejects the original request. |
| `complete` | () => void | Marks the reverification process as complete and retries the original request. |
| `level` | undefined \| "first\_factor" \| "second\_factor" \| "multi\_factor" | The verification level required for the reverification process. |
## Examples
The `useReverification()` hook displays a prebuilt UI when the user needs to reverify their credentials. You can also build a custom UI to handle the reverification process yourself. Use the following tabs to see examples of either option.
### Handle reverification for an action
The following example demonstrates how to use the `useReverification()` hook to require a user to reverify their credentials before being able to update their primary email address. It also demonstrates how to handle the cancellation of the reverification process.
```tsx {{ filename: 'components/UpdateUserEmail.tsx', collapsible: true }}
import { useReverification, useUser } from '@clerk/react-router'
import { isClerkRuntimeError, isReverificationCancelledError } from '@clerk/shared'
export function UpdateUserEmail() {
// Use `useUser()` to get the current user's `User` object
// `User` includes the `update()` method to update the user's primary email address
const { user } = useUser()
// Use `useReverification()` to enhance the `update()` method
// to handle the reverification process
const changePrimaryEmail = useReverification((emailAddressId: string) =>
user?.update({ primaryEmailAddressId: emailAddressId }),
)
const handleClick = async (emailAddressId: string) => {
try {
await changePrimaryEmail(emailAddressId)
} catch (e) {
// Handle if user cancels the reverification process
if (isClerkRuntimeError(e) && isReverificationCancelledError(e)) {
console.error('User cancelled reverification', e.code)
}
// Handle other errors
// See https://clerk.com/docs/custom-flows/error-handling
// for more info on error handling
console.error(JSON.stringify(e, null, 2))
}
}
return (
Your primary email address is {user?.primaryEmailAddress?.emailAddress}
)
}
```
### Handle reverification for a fetcher function
The following example demonstrates how to use the `useReverification()` hook to enhance a fetcher function that fetches data from a route that requires reverification. For examples on how to set up a route that requires reverification, see the [guide on reverification](/docs/guides/secure/reverification).
```tsx {{ filename: 'components/AccountBalance.tsx' }}
import { useReverification } from '@clerk/react-router'
import { isClerkRuntimeError, isReverificationCancelledError } from '@clerk/shared'
import { useState } from 'react'
export function AccountBalance() {
const [balance, setBalance] = useState(null)
const accountBalance = useReverification(async () => {
const response = await fetch('/api/balance')
return await response.json()
})
const handleClick = async () => {
try {
const accountBalanceResponse = await accountBalance()
setBalance(accountBalanceResponse.amount)
} catch (e) {
// Handle if user cancels the reverification process
if (isClerkRuntimeError(e) && isReverificationCancelledError(e)) {
console.error('User cancelled reverification', e.code)
}
// Handle other errors
// See https://clerk.com/docs/custom-flows/error-handling
// for more info on error handling
console.error(JSON.stringify(e, null, 2))
}
}
return (
Your account balance is {balance ? `$${balance}` : '$******'} handleClick()}>See account balance
)
}
```
The following example demonstrates how to build a custom UI when using the `useReverification()` hook. In the example, the `useReverification()` hook is used to require a user to reverify their credentials before being able to update their primary email address. It requires two components: the `` component displays the list of email addresses to choose from and it renders the second component, ``, which handles the reverification process.
The example handles first factor verification using an email code, so you will need to have the [**Email verification code**](/docs/guides/configure/auth-strategies/sign-up-sign-in-options#email) setting enabled for your application. But you can adapt this example to handle any type of verification level or strategy.
The `` component uses `useReverification()` to enhance the `update()` method, requiring the user to reverify their credentials before being able to update their primary email address.
The `useReverification()` hook provides the `onNeedsReverification` option, which is a handler for building a custom UI. It provides four properties: `level`, `complete`, `cancel`, and `inProgress`. The example tracks these using the `verificationState` state variable.
* The `level` property determines the verification level required for the reverification process. This example only handles first factor verification, which is done in the `` component.
* The `complete` and `cancel` properties are the steps of the reverification process, which is also done in the `` component.
* The `inProgress` property is used to track the state of the reverification process. When the user selects the "Make primary" button, it triggers the reverification process and sets the `inProgress` property is `true`, which displays the `` component.
```tsx {{ filename: 'components/UpdateUserEmail.tsx', collapsible: true }}
import { useReverification, useUser } from '@clerk/react-router'
import { isClerkRuntimeError, isReverificationCancelledError } from '@clerk/shared'
import { useState } from 'react'
import type { SessionVerificationLevel } from '@clerk/types'
import { VerificationComponent } from './VerificationComponent'
export function UpdateUserEmail() {
// Use `useUser()` to get the current user's `User` object
// `User` includes the `update()` method to update the user's primary email address
const { user } = useUser()
// TODO: Update to use exported type once available
const [verificationState, setVerificationState] = useState<
| {
complete: () => void
cancel: () => void
level: SessionVerificationLevel | undefined
inProgress: boolean
}
| undefined
>(undefined)
// Use `useReverification()` to enhance the `update()` method
// to handle the reverification process
const changePrimaryEmail = useReverification(
(emailAddressId: string) => user?.update({ primaryEmailAddressId: emailAddressId }),
{
onNeedsReverification: ({ complete, cancel, level }) => {
setVerificationState({
complete,
cancel,
level,
inProgress: true,
})
},
},
)
const handleClick = async (emailAddressId: string) => {
try {
await changePrimaryEmail(emailAddressId)
} catch (e) {
// Handle if user cancels the reverification process
if (isClerkRuntimeError(e) && isReverificationCancelledError(e)) {
console.error('User cancelled reverification', e.code)
}
// Handle other errors
// See https://clerk.com/docs/custom-flows/error-handling
// for more info on error handling
console.error(JSON.stringify(e, null, 2))
}
}
return (
Your primary email address is {user?.primaryEmailAddress?.emailAddress}
)
}
```
The `` component handles the reverification process. It uses the `level` property to determine the verification level, which is set to `first_factor`. First, it finds the determined starting first factor from the supported first factors. Then, it prepares the first factor verification using the `strategy` (`email_code` in this case) and `emailAddressId` properties. Finally, it attempts to verify the session with email code provided by the user. If the verification is successful, the `onComplete()` handler is called to complete the reverification process.
```tsx {{ filename: 'components/VerificationComponent.tsx', collapsible: true }}
import { useEffect, useRef, useState } from 'react'
import { useSession } from '@clerk/react-router'
import type {
EmailCodeFactor,
SessionVerificationLevel,
SessionVerificationResource,
} from '@clerk/types'
export function VerificationComponent({
level = 'first_factor',
onComplete,
onCancel,
}: {
level: SessionVerificationLevel | undefined
onComplete: () => void
onCancel: () => void
}) {
const { session } = useSession()
const [code, setCode] = useState('')
const reverificationRef = useRef(undefined)
const [determinedStartingFirstFactor, setDeterminedStartingFirstFactor] = useState<
EmailCodeFactor | undefined
>()
useEffect(() => {
if (reverificationRef.current) {
return
}
session?.startVerification({ level }).then(async (response) => {
reverificationRef.current = response
await prepareEmailVerification(response)
})
}, [])
const prepareEmailVerification = async (verificationResource: SessionVerificationResource) => {
// To simplify the example we will only handle the first factor verification
if (verificationResource.status === 'needs_first_factor') {
// Determine the starting first factor from the supported first factors
const determinedStartingFirstFactor = verificationResource.supportedFirstFactors?.filter(
(factor) => factor.strategy === 'email_code',
)[0]
if (determinedStartingFirstFactor) {
setDeterminedStartingFirstFactor(determinedStartingFirstFactor)
// Prepare the first factor verification with the determined starting first factor
await session?.prepareFirstFactorVerification({
strategy: determinedStartingFirstFactor.strategy,
emailAddressId: determinedStartingFirstFactor?.emailAddressId,
})
}
}
}
const handleVerificationAttempt = async () => {
try {
// Attempt to verify the session with the provided code
await session?.attemptFirstFactorVerification({
strategy: 'email_code',
code,
})
onComplete()
} catch (e) {
// Any error from the attempt to verify the session can be handled here
console.error('Error verifying session', e)
}
}
if (!determinedStartingFirstFactor) {
return null
}
return (
Enter verification code sent to {determinedStartingFirstFactor.safeIdentifier || ''}
)
}
```
## Related guides
See the custom flowA **custom flow** refers to a user interface built entirely from scratch using the Clerk API. Learn more about [custom flows](/docs/guides/development/custom-flows/overview). guides for examples of how to use the `useReverification()` hook, such as the [Add a phone number to a user's account](/docs/guides/development/custom-flows/account-updates/add-phone) guide.
---
title: "`useOrganizationList()`"
description: Access and manage the current user's Organization list in your
React application with Clerk's useOrganizationList() hook.
sdk: chrome-extension, expo, nextjs, react, react-router, remix,
tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-organization-list
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: chrome-extension,expo,nextjs,react,react-router,remix,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,go,astro,nuxt,vue,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/hooks/use-organization-list.mdx
---
The `useOrganizationList()` hook provides access to the current user's Organization memberships, invitations, and suggestions. It also includes methods for creating new Organizations and managing the Active OrganizationA user can be a member of multiple Organizations, but only one can be active at a time. The **Active Organization** determines which Organization-specific data the user can access and which Role and related Permissions they have within the Organization..
## Parameters
`useOrganizationList()` accepts a single object with the following properties:
| Property | Type | Description |
| ----------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `userInvitations?` | true \| \{ initialPage?: number; pageSize?: number; \} & \{ status?: "expired" \| "pending" \| "accepted" \| "revoked"; \} & \{ infinite?: boolean; keepPreviousData?: boolean; \} | If set to `true`, all default properties will be used. Otherwise, accepts an object with the following optional properties:
`status`: A string that filters the invitations by the provided status.
Any of the properties described in Shared properties.
|
| `userMemberships?` | true \| \{ initialPage?: number; pageSize?: number; \} & object & \{ infinite?: boolean; keepPreviousData?: boolean; \} | If set to `true`, all default properties will be used. Otherwise, accepts an object with the following optional properties:
Any of the properties described in Shared properties.
|
| `userSuggestions?` | true \| \{ initialPage?: number; pageSize?: number; \} & \{ status?: "pending" \| "accepted" \| ("pending" \| "accepted")\[]; \} & \{ infinite?: boolean; keepPreviousData?: boolean; \} | If set to `true`, all default properties will be used. Otherwise, accepts an object with the following optional properties:
`status`: A string that filters the suggestions by the provided status.
Any of the properties described in Shared properties.
|
> \[!WARNING]
> By default, the `userMemberships`, `userInvitations`, and `userSuggestions` attributes are not populated. To fetch and paginate the data, you must pass `true` or an object with the desired properties.
### Shared properties
Optional properties that are shared across the `userMemberships`, `userInvitations`, and `userSuggestions` properties.
| Property | Type | Description |
| --------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `initialPage?` | `number` | A number that specifies which page to fetch. For example, if `initialPage` is set to 10, it will skip the first 9 pages and fetch the 10th page. Defaults to `1`. |
| `pageSize?` | `number` | A number that specifies the maximum number of results to return per page. Defaults to `10`. |
| Name | Type | Description |
| ------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `infinite?` | `boolean` | If `true`, newly fetched data will be appended to the existing list rather than replacing it. Useful for implementing infinite scroll functionality. Defaults to `false`. |
| `keepPreviousData?` | `boolean` | If `true`, the previous data will be kept in the cache until new data is fetched. Defaults to `false`. |
## Returns
| Property | Type | Description |
| ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `createOrganization` | undefined \| (CreateOrganizationParams: CreateOrganizationParams) => Promise\<OrganizationResource\> | A function that returns a `Promise` which resolves to the newly created `Organization`. |
| `isLoaded` | `boolean` | A boolean that indicates whether Clerk has completed initialization and there is an authenticated user. Initially `false`, becomes `true` once Clerk loads with a user. |
| `setActive` | undefined \| (setActiveParams: SetActiveParams) => Promise\ | A function that sets the active session and/or organization. |
| `userInvitations` | PaginatedResourcesWithDefault\<UserOrganizationInvitationResource\> \| PaginatedResources\<UserOrganizationInvitationResource, T\["userInvitations"] *extends* \{ infinite: true; \} ? true : false\> | Returns `PaginatedResources` which includes a list of the user's organization invitations. |
| `userMemberships` | PaginatedResourcesWithDefault\<OrganizationMembershipResource\> \| PaginatedResources\<OrganizationMembershipResource, T\["userMemberships"] *extends* \{ infinite: true; \} ? true : false\> | Returns `PaginatedResources` which includes a list of the user's organization memberships. |
| `userSuggestions` | PaginatedResourcesWithDefault\<OrganizationSuggestionResource\> \| PaginatedResources\<OrganizationSuggestionResource, T\["userSuggestions"] *extends* \{ infinite: true; \} ? true : false\> | Returns `PaginatedResources` which includes a list of suggestions for organizations that the user can join. |
### `CreateOrganizationParams`
| Property | Type | Description |
| ------------------------- | -------- | ----------------------------- |
| `name` | `string` | The name of the organization. |
| `slug?` | `string` | The slug of the organization. |
### `PaginatedResources`
| Property | Type | Description |
| ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `count` | `number` | The total count of data that exist remotely. |
| `data` | T\[] | An array that contains the fetched data. For example, for the `memberships` attribute, data will be an array of OrganizationMembership objects. |
| `error` | null \| ClerkAPIResponseError | Clerk's API response error object. |
| `fetchNext` | () => void | A function that triggers the next page to be loaded. This is the same as `fetchPage(page => Math.min(pageCount, page + 1))`. |
| `fetchPage` | `ValueOrSetter`\<`number`\> | A function that triggers a specific page to be loaded. |
| `fetchPrevious` | () => void | A function that triggers the previous page to be loaded. This is the same as `fetchPage(page => Math.max(0, page - 1))`. |
| `hasNextPage` | `boolean` | A boolean that indicates if there are available pages to be fetched. |
| `hasPreviousPage` | `boolean` | A boolean that indicates if there are available pages to be fetched. |
| `isError` | `boolean` | A boolean that indicates the request failed. |
| `isFetching` | `boolean` | A boolean that is `true` if there is an ongoing request or a revalidation. |
| `isLoading` | `boolean` | A boolean that is `true` if there is an ongoing request and there is no fetched data. |
| `page` | `number` | The current page. |
| `pageCount` | `number` | The total amount of pages. It is calculated based on `count`, `initialPage`, and `pageSize`. |
| `revalidate` | () => Promise\ | A function that triggers a revalidation of the current page. |
| `setData` | `Infinite` *extends* `true` ? `CacheSetter`\<(undefined \| ClerkPaginatedResponse\)\[]\> : `CacheSetter`\<undefined \| ClerkPaginatedResponse\\> | A function that allows you to set the data manually. |
To see the different Organization features integrated into one application, take a look at our [Organizations demo repository](https://github.com/clerk/organizations-demo).
## Examples
### Expanding and paginating attributes
To keep network usage to a minimum, developers are required to opt-in by specifying which resource they need to fetch and paginate through. So by default, the `userMemberships`, `userInvitations`, and `userSuggestions` attributes are not populated. You must pass `true` or an object with the desired properties to fetch and paginate the data.
```jsx
// userMemberships.data will never be populated
const { userMemberships } = useOrganizationList()
// Use default values to fetch userMemberships, such as initialPage = 1 and pageSize = 10
const { userMemberships } = useOrganizationList({
userMemberships: true,
})
// Pass your own values to fetch userMemberships
const { userMemberships } = useOrganizationList({
userMemberships: {
pageSize: 20,
initialPage: 2, // skips the first page
},
})
// Aggregate pages in order to render an infinite list
const { userMemberships } = useOrganizationList({
userMemberships: {
infinite: true,
},
})
```
### Infinite pagination
The following example demonstrates how to use the `infinite` property to fetch and append new data to the existing list. The `userMemberships` attribute will be populated with the first page of the user's Organization memberships. When the "Load more" button is clicked, the `fetchNext` helper function will be called to append the next page of memberships to the list.
```tsx {{ filename: 'components/JoinedOrganizations.tsx' }}
import { useOrganizationList } from '@clerk/react-router'
export function JoinedOrganizations() {
const { isLoaded, setActive, userMemberships } = useOrganizationList({
userMemberships: {
infinite: true,
},
})
// Handle loading state
if (!isLoaded) return
userMemberships.fetchNext()}>
Load more
>
)
}
```
### Simple pagination
The following example demonstrates how to use the `fetchPrevious` and `fetchNext` helper functions to paginate through the data. The `userInvitations` attribute will be populated with the first page of invitations. When the "Previous page" or "Next page" button is clicked, the `fetchPrevious` or `fetchNext` helper function will be called to fetch the previous or next page of invitations.
Notice the difference between this example's pagination and the infinite pagination example above.
```tsx {{ filename: 'components/UserInvitationsTable.tsx' }}
import { useOrganizationList } from '@clerk/react-router'
export function UserInvitationsTable() {
const { isLoaded, userInvitations } = useOrganizationList({
userInvitations: {
infinite: true,
keepPreviousData: true,
},
})
// Handle loading state
if (!isLoaded || userInvitations.isLoading) return
Loading...
return (
<>
Email
Org name
{userInvitations.data?.map((inv) => (
{inv.emailAddress}
{inv.publicOrganizationData.name}
))}
Prev
Next
>
)
}
```
## Related guides
* [Build a custom Organization switcher](/docs/guides/development/custom-flows/organizations/organization-switcher)
* Use Clerk's API to build a custom flow for switching between Organizations
***
* [Create Organizations](/docs/guides/development/custom-flows/organizations/create-organizations)
* Use Clerk's API to build a custom flow for creating Organizations
***
* [Manage a user's Organization invitations](/docs/guides/development/custom-flows/organizations/manage-user-org-invitations)
* Use Clerk's API to build a custom flow for managing user's Organization invitations
---
title: useSession()
description: Access and manage the current user's session in your React
application with Clerk's useSession() hook.
sdk: chrome-extension, expo, nextjs, react, react-router, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-session
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: chrome-extension,expo,nextjs,react,react-router,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,remix,go,astro,nuxt,vue,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/hooks/use-session.mdx
---
The `useSession()` hook provides access to the current user's Session object, as well as helpers for setting the active session.
## Returns
There are multiple variants of this type available which you can select by clicking on one of the tabs.
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `false` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `undefined` | A boolean that indicates whether a user is currently signed in. |
| `session` | `undefined` | The current session for the user. |
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `true` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `false` | A boolean that indicates whether a user is currently signed in. |
| `session` | `null` | The current session for the user. |
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `true` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `boolean` | A boolean that indicates whether a user is currently signed in. |
| `session` | SignedInSessionResource | The current session for the user. |
## Example
### Access the `Session` object
The following example uses the `useSession()` hook to access the `Session` object, which has the `lastActiveAt` property. The `lastActiveAt` property is a `Date` object used to show the time the session was last active.
```tsx {{ filename: 'app/routes/home.tsx' }}
import { useSession } from '@clerk/react-router'
export default function Home() {
const { isLoaded, session, isSignedIn } = useSession()
// Handle loading state
if (!isLoaded) return
Loading...
// Protect the page from unauthenticated users
if (!isSignedIn) return
Sign in to view this page
return (
This session has been active since {session.lastActiveAt.toLocaleString()}
)
}
```
---
title: useSignIn()
description: Access and manage the current user's sign-in state in your React
application with Clerk's useSignIn() hook.
sdk: chrome-extension, expo, nextjs, react, react-router, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-sign-in
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: chrome-extension,expo,nextjs,react,react-router,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,remix,go,astro,nuxt,vue,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/hooks/use-sign-in.mdx
---
The `useSignIn()` hook provides access to the SignIn object, which allows you to check the current state of a sign-in attempt and manage the sign-in flow. You can use this to create a [custom sign-in flow](/docs/guides/development/custom-flows/overview#sign-in-flow).
## Returns
There are multiple variants of this type available which you can select by clicking on one of the tabs.
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `false` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `setActive` | `undefined` | A function that sets the active session. See the reference doc. |
| `signIn` | `undefined` | An object that contains the current sign-in attempt status and methods to create a new sign-in attempt. |
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `true` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `setActive()` | (setActiveParams: SetActiveParams) => Promise\ | A function that sets the active session. See the reference doc. |
| `signIn` | SignInResource | An object that contains the current sign-in attempt status and methods to create a new sign-in attempt. |
## Examples
### Check the current state of a sign-in
The following example uses the `useSignIn()` hook to access the SignIn object, which contains the current sign-in attempt status and methods to create a new sign-in attempt. The `isLoaded` property is used to handle the loading state.
```tsx {{ filename: 'app/routes/sign-in.tsx' }}
import { useSignIn } from '@clerk/react-router'
export default function SignInPage() {
const { isLoaded, signIn } = useSignIn()
// Handle loading state
if (!isLoaded) return
Loading...
return
The current sign-in attempt status is {signIn?.status}.
}
```
### Create a custom sign-in flow with `useSignIn()`
The `useSignIn()` hook can also be used to build fully custom sign-in flows, if Clerk's prebuilt components don't meet your specific needs or if you require more control over the authentication flow. Different sign-in flows include email and password, email and phone codes, email links, and multifactor (MFA). To learn more about using the `useSignIn()` hook to create custom flows, see the [custom flow guides](/docs/guides/development/custom-flows/overview).
---
title: useSignUp()
description: Access and manage the current user's sign-up state in your React
application with Clerk's useSignUp() hook.
sdk: chrome-extension, expo, nextjs, react, react-router, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-sign-up
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: chrome-extension,expo,nextjs,react,react-router,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,remix,go,astro,nuxt,vue,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/hooks/use-sign-up.mdx
---
The `useSignUp()` hook provides access to the SignUp object, which allows you to check the current state of a sign-up attempt and manage the sign-up flow. You can use this to create a [custom sign-up flow](/docs/guides/development/custom-flows/overview#sign-up-flow).
## Returns
There are multiple variants of this type available which you can select by clicking on one of the tabs.
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `false` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `setActive` | `undefined` | A function that sets the active session. See the reference doc. |
| `signUp` | `undefined` | An object that contains the current sign-up attempt status and methods to create a new sign-up attempt. |
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `true` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `setActive()` | (setActiveParams: SetActiveParams) => Promise\ | A function that sets the active session. See the reference doc. |
| `signUp` | SignUpResource | An object that contains the current sign-up attempt status and methods to create a new sign-up attempt. |
## Examples
### Check the current state of a sign-up
The following example uses the `useSignUp()` hook to access the SignUp object, which contains the current sign-up attempt status and methods to create a new sign-up attempt. The `isLoaded` property is used to handle the loading state.
```tsx {{ filename: 'app/routes/sign-up.tsx' }}
import { useSignUp } from '@clerk/react-router'
export default function SignUpPage() {
const { isLoaded, signUp } = useSignUp()
// Handle loading state
if (!isLoaded) return
Loading...
return
The current sign-up attempt status is {signUp?.status}.
}
```
### Create a custom sign-up flow with `useSignUp()`
The `useSignUp()` hook can also be used to build fully custom sign-up flows, if Clerk's prebuilt components don't meet your specific needs or if you require more control over the authentication flow. Different sign-up flows include email and password, email and phone codes, email links, and multifactor (MFA). To learn more about using the `useSignUp()` hook to create custom flows, see the [custom flow guides](/docs/guides/development/custom-flows/overview).
---
title: useUser()
description: Access and manage the current user's data in your React application
with Clerk's useUser() hook.
sdk: chrome-extension, expo, nextjs, react, react-router, tanstack-react-start
sdkScoped: "true"
canonical: /docs/:sdk:/reference/hooks/use-user
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: chrome-extension,expo,nextjs,react,react-router,tanstack-react-start
notAvailableSdks: js-frontend,android,ios,expressjs,fastify,remix,go,astro,nuxt,vue,ruby,js-backend
activeSdk: react-router
sourceFile: /docs/reference/hooks/use-user.mdx
---
The `useUser()` hook provides access to the current user's User object, which contains all the data for a single user in your application and provides methods to manage their account. This hook also allows you to check if the user is signed in and if Clerk has loaded and initialized.
## Returns
There are multiple variants of this type available which you can select by clicking on one of the tabs.
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `false` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `undefined` | A boolean that returns `true` if the user is signed in. |
| `user` | `undefined` | The `User` object for the current user. |
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `true` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `false` | A boolean that returns `true` if the user is signed in. |
| `user` | `null` | The `User` object for the current user. |
| Name | Type | Description |
| ------ | ------ | ------ |
| `isLoaded` | `true` | A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. |
| `isSignedIn` | `true` | A boolean that returns `true` if the user is signed in. |
| `user` | UserResource | The `User` object for the current user. |
## Examples
### Get the current user
The following example uses the `useUser()` hook to access the User object, which contains the current user's data such as their full name. The `isLoaded` and `isSignedIn` properties are used to handle the loading state and to check if the user is signed in, respectively.
```tsx {{ filename: 'app/routes/home.tsx' }}
import { useUser } from '@clerk/react-router'
export default function Home() {
const { isSignedIn, user, isLoaded } = useUser()
// Handle loading state
if (!isLoaded) return
Loading...
// Protect the page from unauthenticated users
if (!isSignedIn) return
Sign in to view this page
return
Hello {user.firstName}!
}
```
### Update user data
The following example uses the `useUser()` hook to access the User object, which calls the update() method to update the current user's information.
```tsx {{ filename: 'app/routes/home.tsx' }}
import { useUser } from '@clerk/react-router'
export default function Home() {
const { isSignedIn, isLoaded, user } = useUser()
// Handle loading state
if (!isLoaded) return
Loading...
// Protect the page from unauthenticated users
if (!isSignedIn) return
>
)
}
```
### Reload user data
The following example uses the `useUser()` hook to access the User object, which calls the reload() method to get the latest user's information.
```tsx {{ filename: 'app/routes/home.tsx' }}
import { useUser } from '@clerk/react-router'
export default function Home() {
const { isSignedIn, isLoaded, user } = useUser()
// Handle loading state
if (!isLoaded) return
Loading...
// Protect the page from unauthenticated users
if (!isSignedIn) return
Sign in to view this page
const updateUser = async () => {
// Update data via an API endpoint
const updateMetadata = await fetch('/api/updateMetadata', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
role: 'admin',
}),
})
// Check if the update was successful
if ((await updateMetadata.json()).message !== 'success') {
throw new Error('Error updating')
}
// If the update was successful, reload the user data
await user.reload()
}
return (
<>
Update your metadata
user role: {user.publicMetadata.role}
>
)
}
```
---
title: Fastify Quickstart
description: Learn how to integrate Clerk for secure authentication and user
management into your application using a Fastify backend.
sdk: nextjs, react, js-frontend, chrome-extension, expo, android, ios,
expressjs, fastify, react-router, remix, tanstack-react-start, go, astro,
nuxt, vue, ruby, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/getting-started/quickstart
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,react,js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
notAvailableSdks: ""
activeSdk: fastify
sourceFile: /docs/getting-started/quickstart.fastify.mdx
---
Learn how to integrate Clerk into your Fastify backend for secure user authentication and management. This guide uses TypeScript and allows you to choose your frontend framework.
> \[!IMPORTANT]
> [Fastify is only compatible with Next.js versions 13.4 and below](https://github.com/fastify/fastify-nextjs). If you're using a newer version of Next.js, consider using a different backend framework that supports the latest Next.js features.
>
> This guide uses ECMAScript Modules (ESM). To use ESM in your project, you must include `"type": "module"` in your `package.json`.
## Install `@clerk/fastify`
[Clerk's Fastify SDK](https://github.com/clerk/javascript/tree/main/packages/fastify) provides a range of backend utilities to simplify user authentication and management in your application.
Run the following command to install the SDK:
```npm
npm install @clerk/fastify
```
## Set your Clerk API keys
Add the following keys to your `.env` file. These keys can always be retrieved from the [**API keys**](https://dashboard.clerk.com/~/api-keys) page in the Clerk Dashboard.
1. In the Clerk Dashboard, navigate to the [**API keys**](https://dashboard.clerk.com/~/api-keys) page.
2. In the **Quick Copy** section, copy your Clerk Publishable and Secret Keys.
3. Paste your keys into your `.env` file.
The final result should resemble the following:
```env {{ filename: '.env' }}
CLERK_PUBLISHABLE_KEY={{pub_key}}
CLERK_SECRET_KEY={{secret}}
```
## Configure `clerkPlugin()` for all routes
The `clerkPlugin()` function is a Fastify plugin provided by Clerk to integrate authentication into your Fastify application. To ensure that Clerk's authentication and user management features are applied across your Fastify application, configure the `clerkPlugin()` to handle all routes or limit it to specific ones.
The following example registers the plugin for all routes. To register the plugin for specific routes, see the [reference docs](/docs/reference/fastify/overview).
> \[!IMPORTANT]
> The `dotenv/config` module must be imported before any Clerk modules. This order is important because Clerk instances are created during the import process and rely on environment variables, such as API keys, to be initialized correctly. For more information, refer to the [Fastify docs](https://fastify.dev/docs/latest/Guides/Getting-Started/#loading-order-of-your-plugins).
```ts {{ filename: 'index.ts' }}
import 'dotenv/config'
import Fastify from 'fastify'
import { clerkPlugin } from '@clerk/fastify'
const fastify = Fastify({ logger: true })
fastify.register(clerkPlugin)
const start = async () => {
try {
await fastify.listen({ port: 8080 })
} catch (error) {
fastify.log.error(error)
process.exit(1)
}
}
start()
```
## Protect your routes using `getAuth()`
The [`getAuth()`](/docs/reference/fastify/overview#get-auth) helper retrieves the current user's authentication state from the `request` object. It returns the Auth object{{ target: '_blank' }}.
The following example uses `getAuth()` to protect a route and load the user's data. If the user is authenticated, their `userId` is passed to clerkClient.users.getUser(){{ target: '_blank' }} to get the current user's User{{ target: '_blank' }} object. If not authenticated, the request is rejected with a `401` status code.
```ts
// dotenv must be imported before @clerk/fastify
import 'dotenv/config'
import Fastify from 'fastify'
import { clerkClient, clerkPlugin, getAuth } from '@clerk/fastify'
const fastify = Fastify({ logger: true })
fastify.register(clerkPlugin)
// Use `getAuth()` to protect this route
fastify.get('/protected', async (request, reply) => {
try {
// Use `getAuth()` to access `isAuthenticated` and the user's ID
const { isAuthenticated, userId } = getAuth(request)
// If user isn't authenticated, return a 401 error
if (!isAuthenticated) {
return reply.code(401).send({ error: 'User not authenticated' })
}
// Use `clerkClient` to access Clerk's JS Backend SDK methods
// and get the user's User object
const user = await clerkClient.users.getUser(userId)
return reply.send({
message: 'User retrieved successfully',
user,
})
} catch (error) {
fastify.log.error(error)
return reply.code(500).send({ error: 'Failed to retrieve user' })
}
})
const start = async () => {
try {
await fastify.listen({ port: 8080 })
} catch (error) {
fastify.log.error(error)
process.exit(1)
}
}
start()
```
---
title: Clerk Billing for B2C SaaS
description: Clerk Billing is a feature that allows you to create and manage
Plans and Features for your application.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/billing/for-b2c
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: fastify
sourceFile: /docs/guides/billing/for-b2c.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing for B2C SaaS allows you to create Plans and manage Subscriptions **for individual users** in your application. If you'd like to charge companies or organizations, see Billing for B2B SaaS. You can also combine both B2C and B2B Billing in the same application.
## Enable Billing
To enable Billing for your application, navigate to the [**Billing Settings**](https://dashboard.clerk.com/~/billing/settings) page in the Clerk Dashboard. This page will guide you through enabling Billing for your application.
Clerk Billing costs the same as using Stripe Billing directly, just 0.7% per transaction, plus transaction fees which are paid directly to Stripe. Clerk Billing is **not** the same as Stripe Billing. Plans and pricing are managed directly through the Clerk Dashboard and won't sync with your existing Stripe products or plans. Clerk uses Stripe **only** for payment processing, so you don't need to set up Stripe Billing.
### Payment gateway
Once you have enabled Billing, you will see the following **Payment gateway** options for collecting payments via Stripe:
* **Clerk development gateway**: A shared **test** Stripe account used for development instances. This allows developers to test and build Billing flows **in development** without needing to create and configure a Stripe account.
* **Stripe account**: Use your own Stripe account for production. **A Stripe account created for a development instance cannot be used for production**. You will need to create a separate Stripe account for your production environment.
## Create a Plan
Subscription Plans are what your users subscribe to. There is no limit to the number of Plans you can create.
To create a Plan, navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard. Here, you can create, edit, and delete Plans. To setup B2C Billing, select the **Plans for Users** tab and select **Add Plan**. When creating a Plan, you can also create Features for the Plan; see the next section for more information.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's a user Plan, it can appear in the `` component. When creating or editing a Plan, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Add Features to a Plan
[Features](/docs/guides/secure/features) make it easy to give entitlements to your Plans. You can add any number of Features to a Plan.
You can add a Feature to a Plan when you are creating a Plan. To add it after a Plan is created:
1. Navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard.
2. Select the Plan you'd like to add a Feature to.
3. In the **Features** section, select **Add Feature**.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's a user Plan, it can appear in the `` component. When adding a Feature to a Plan, it will also automatically appear in the corresponding Plan. When creating or editing a Feature, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Create a pricing page
You can create a pricing page by using the \ component. This component displays a table of Plans and Features that users can subscribe to. **It's recommended to create a dedicated page**, as shown in the following example.
> \[!NOTE]
> To see an example of how to create a pricing table page, please select one of the frontend SDKs on the sidebar.
## Control access with Features and Plans
You can use Clerk's Features and Plans to gate access to the content. There are a few ways to do this, but the recommended approach is to either use the has() method or the \ component.
The `has()` method is available for any JavaScript framework, while `` is only available for React-based frameworks.
### Example: Using `has()`
Use the `has()` method to test if the user has access to a **Plan**:
```jsx
const hasPremiumAccess = has({ plan: 'gold' })
```
Or a **Feature**:
```jsx
const hasPremiumAccess = has({ feature: 'widgets' })
```
The has() method is a server-side helper that checks if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan) and returns a boolean value. `has()` is available on the auth object, which you will access differently depending on the framework you are using.
The following example demonstrates how to use `has()` to check if a user has a Plan.
```tsx {{ filename: 'src/routes/bronze-content.ts' }}
import type { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify'
import { getAuth } from '@clerk/fastify'
export const bronzeContentRoutes = (fastify: FastifyInstance) => {
fastify.get('/bronze-content', async (request: FastifyRequest, reply: FastifyReply) => {
const { has } = getAuth(request)
const hasBronzePlan = has({ plan: 'bronze' })
if (hasBronzePlan) {
reply.send('For Bronze subscribers only')
} else {
reply.send('Only subscribers to the Bronze plan can access this content.')
}
})
}
```
The following example demonstrates how to use `has()` to check if a user has a Feature.
```ts {{ filename: 'src/routes/premium-content.ts' }}
import type { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify'
import { getAuth } from '@clerk/fastify'
export const premiumContentRoutes = (fastify: FastifyInstance) => {
fastify.get('/premium-content', async (request: FastifyRequest, reply: FastifyReply) => {
const { has } = getAuth(request)
const hasPremiumAccess = has({ feature: 'premium_access' })
if (!hasPremiumAccess) {
reply.send('Only subscribers with the Premium Access feature can access this content.')
} else {
reply.send('Our Exclusive Content')
}
})
}
```
### Example: Using ``
The \ component protects content or even entire routes by checking if the user has been granted a specific type of access control (Role, Permission, Feature, or Plan). You can pass a `fallback` prop to `` that will be rendered if the user does not have the access control.
The following example demonstrates how to use `` to protect a page by checking if the user has a Plan.
> \[!NOTE]
> To see an example of how to use the `Protect` component, please select one of the frontend SDKs on the sidebar.
The following example demonstrates how to use `` to protect a page by checking if the user has a Feature.
> \[!NOTE]
> To see an example of how to use the `Protect` component, please select one of the frontend SDKs on the sidebar.
---
title: Clerk Billing for B2B SaaS
description: Clerk Billing is a feature that allows you to create and manage
Plans and Features for your application.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/billing/for-b2b
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: fastify
sourceFile: /docs/guides/billing/for-b2b.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing for B2B SaaS allows you to create Plans and manage Subscriptions **for companies or organizations** in your application. If you'd like to charge individual users, see Billing for B2C SaaS. You can also combine both B2C and B2B Billing in the same application.
## Enable Billing
To enable Billing for your application, navigate to the [**Billing Settings**](https://dashboard.clerk.com/~/billing/settings) page in the Clerk Dashboard. This page will guide you through enabling Billing for your application.
Clerk Billing costs the same as using Stripe Billing directly, just 0.7% per transaction, plus transaction fees which are paid directly to Stripe. Clerk Billing is **not** the same as Stripe Billing. Plans and pricing are managed directly through the Clerk Dashboard and won't sync with your existing Stripe products or plans. Clerk uses Stripe **only** for payment processing, so you don't need to set up Stripe Billing.
### Payment gateway
Once you have enabled Billing, you will see the following **Payment gateway** options for collecting payments via Stripe:
* **Clerk development gateway**: A shared **test** Stripe account used for development instances. This allows developers to test and build Billing flows **in development** without needing to create and configure a Stripe account.
* **Stripe account**: Use your own Stripe account for production. **A Stripe account created for a development instance cannot be used for production**. You will need to create a separate Stripe account for your production environment.
## Create a Plan
Subscription Plans are what your customers subscribe to. There is no limit to the number of Plans you can create. If your Clerk instance has existing [Custom Permissions](/docs/guides/organizations/roles-and-permissions), the corresponding Features from those Permissions will automatically be added to the free Plan for Orgs. This ensures that Organization members get the same set of Custom Permissions when Billing is enabled, because all Organizations start on the free Plan.
To create a Plan, navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard. Here, you can create, edit, and delete Plans. To setup B2B Billing, select the **Plans for Organizations** tab and select **Add Plan**. When creating a Plan, you can also create [Features](/docs/guides/secure/features) for the Plan; see the next section for more information.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's an Organization Plan, it can appear in the `` component. When creating or editing a Plan, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Add Features to a Plan
[Features](/docs/guides/secure/features) make it easy to give entitlements to your Plans. You can add any number of Features to a Plan.
You can add a Feature to a Plan when you are creating a Plan. To add it after a Plan is created:
1. Navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard.
2. Select the Plan you'd like to add a Feature to.
3. In the **Features** section, select **Add Feature**.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's an Organization Plan, it can appear in the `` component. When adding a Feature to a Plan, it will also automatically appear in the corresponding Plan. When creating or editing a Feature, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Create a pricing page
You can create a pricing page by using the \ component. This component displays a table of Plans and Features that customers can subscribe to. **It's recommended to create a dedicated page**, as shown in the following example.
> \[!NOTE]
> To see an example of how to create a pricing table page, please select one of the frontend SDKs on the sidebar.
## Control access with Features, Plans, and Permissions
You can use Clerk's Features, Plans, and Permissions to gate access to content using authorization checksAuthorization checks are checks you perform in your code to determine the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions or access certain content. Learn more about [authorization checks](/docs/guides/secure/authorization-checks).. There are a few ways to do this, but the recommended approach is to either use the has() method or the \ component.
The `has()` method is available for any JavaScript-based framework, while `` is a component, and therefore, is only available for React-based frameworks.
> \[!IMPORTANT]
> Permission-based authorization checks link with Feature-based authorization checks. This means that if you are checking a Custom Permission, it will only work if the Feature part of the Permission key (`org::`) **is a Feature included in the Organization's active Plan**. For example, say you want to check if an Organization member has the Custom Permission `org:teams:manage`, where `teams` is the Feature. Before performing the authorization check, you need to ensure that the user's Organization is subscribed to a Plan that has the `teams` Feature. If the user's Organization is not subscribed to a Plan that has the `teams` Feature, the authorization check will always return `false`, *even if the user has the Custom Permission*.
### Example: Using `has()`
Use the `has()` method to test if the Organization has access to a **Plan**:
```jsx
const hasPremiumAccess = has({ plan: 'gold' })
```
Or a **Feature**:
```jsx
const hasPremiumAccess = has({ feature: 'widgets' })
```
The has() method is a server-side helper that checks if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan) and returns a boolean value. `has()` is available on the auth object, which you will access differently depending on the framework you are using.
> \[!TIP]
> Why aren't Custom Permissions appearing in the session token (JWT) or in API responses (including the result of the `has()` check)?
>
> ***
>
> Custom Permissions will only appear in the session token (JWT) and in API responses (including the result of the `has()` check) if the Feature part of the Permission key (`org::`) **is a Feature included in the Organization's active Plan**. If the Feature is not part of the Plan, the `has()` check for Permissions using that Feature will return `false`, and those Permissions will not be represented in the session token.
>
> For example, say you want to check if an Organization member has the Custom Permission `org:teams:manage`, where `teams` is the Feature. The user's Organization must be subscribed to a Plan that has the `teams` Feature for authorization checks to work. If the user's Organization is not subscribed to a Plan that has the `teams` Feature, the authorization check will always return `false`, *even if the user has the Custom Permission*.
The following example demonstrates how to use `has()` to check if an Organization has a Plan.
```tsx {{ filename: 'src/routes/bronze-content.ts' }}
import type { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify'
import { getAuth } from '@clerk/fastify'
export const bronzeContentRoutes = (fastify: FastifyInstance) => {
fastify.get('/bronze-content', async (request: FastifyRequest, reply: FastifyReply) => {
const { has } = getAuth(request)
const hasBronzePlan = has({ plan: 'bronze' })
if (hasBronzePlan) {
reply.send('For Bronze subscribers only')
} else {
reply.send('Only subscribers to the Bronze plan can access this content.')
}
})
}
```
The following example demonstrates how to use `has()` to check if an Organization has a Feature.
```ts {{ filename: 'src/routes/premium-content.ts' }}
import type { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify'
import { getAuth } from '@clerk/fastify'
export const premiumContentRoutes = (fastify: FastifyInstance) => {
fastify.get('/premium-content', async (request: FastifyRequest, reply: FastifyReply) => {
const { has } = getAuth(request)
const hasPremiumAccess = has({ feature: 'premium_access' })
if (!hasPremiumAccess) {
reply.send('Only subscribers with the Premium Access feature can access this content.')
} else {
reply.send('Our Exclusive Content')
}
})
}
```
The following example demonstrates how to use `has()` to check if an Organization has a Permission.
```tsx {{ filename: 'src/routes/manage-premium-content.ts' }}
import type { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify'
import { getAuth } from '@clerk/fastify'
export const managePremiumContentRoutes = (fastify: FastifyInstance) => {
fastify.get('/manage-premium-content', async (request: FastifyRequest, reply: FastifyReply) => {
const { has } = getAuth(request)
const hasPremiumAccessManage = has({ permission: 'org:premium_access:manage' })
if (hasPremiumAccessManage) {
reply.send('Our Exclusive Content')
} else {
reply.send(
'Only subscribers with the Premium Access Manage permission can access this content.',
)
}
})
}
```
### Example: Using ``
The \ component protects content or even entire routes by checking if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan). You can pass a `fallback` prop to `` that will be rendered if the Organization does not have the access control.
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Plan.
> \[!NOTE]
> To see an example of how to use the `Protect` component, please select one of the frontend SDKs on the sidebar.
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Feature.
> \[!NOTE]
> To see an example of how to use the `Protect` component, please select one of the frontend SDKs on the sidebar.
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Permission.
> \[!NOTE]
> To see an example of how to use the `Protect` component, please select one of the frontend SDKs on the sidebar.
---
title: Clerk Billing webhooks
description: Clerk Billing webhooks allow you to track subscription lifecycles
and monitor payment attempts.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/development/webhooks/billing
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: fastify
sourceFile: /docs/guides/development/webhooks/billing.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing supports webhook events that allow you to track information like subscription lifecycles and payments.
## Subscriptions
A subscription is a top-level container unique to each user or organization. Subscription events can help you track billing changes for each of your customers.
| Event Name | Description |
| - | - |
| `subscription.created` | The top-level subscription is created. This usually happens when a user or organization is created. For existing users and organizations, a subscription will be created when Billing is enabled for the application. |
| `subscription.updated` | The top-level subscription is updated. This event is triggered when any property of the subscription has changed, except for status changes. For example, when the subscription items for the payer change. |
| `subscription.active` | The top-level subscription transitions to active from a non-active status. This happens when any subscription item is set to active, including items from the free default Plan. |
| `subscription.pastDue` | The top-level subscription contains a subscription item that has become past due. |
## Subscription items
A subscription item provides details about the relationship between the payer (user or Organization) and a Plan. A top-level subscription may contain multiple subscription items.
There can only be one `active` subscription item per payer and Plan. In addition, the subscription item for the default Plan will always have the same `id` to allow easier tracking of which users and Organizations are not paid customers.
| Event Name | Description |
| - | - |
| `subscriptionItem.updated` | The subscription item is updated. This event is triggered when a property of the subscription item has changed that does not result in a status change. For example, when a subscription item is renewed and the recurring monthly charge succeeds, the status doesn't change (remains `active`), but `period_start` and `period_end` are updated. This results in a `subscriptionItem.updated` event. |
| `subscriptionItem.active` | The subscription item is set to active. For paid Plans, this happens on successful payment. |
| `subscriptionItem.canceled` | The subscription item is canceled. The payer retains Plan features until the end of the current billing period. |
| `subscriptionItem.upcoming` | The subscription item is set as upcoming after the current billing period. This can happen in the case of a deferred Plan change from a higher-priced to lower-priced Plan. In the case a paid Plan is canceled, the subscription item for the default, free Plan will be set as `upcoming`. |
| `subscriptionItem.ended` | The subscription item has ended. |
| `subscriptionItem.abandoned` | The subscription item is abandoned. This can happen to `upcoming` subscription items if the payer subscribes to another Plan, or re-subscribes to a currently canceled Plan. |
| `subscriptionItem.incomplete` | The subscription item is incomplete. This means the payer has started a checkout for a Plan, but the payment hasn't been successfully processed yet. Once payment succeeds, the subscription item transitions to an `active` status. |
| `subscriptionItem.pastDue` | The subscription item is past due because a recurring charge has failed. |
| `subscriptionItem.freeTrialEnding` | The subscription item is a free trial and is ending soon. This event is sent three days before the trial ends. If the trial is shorter than three days, it's sent immediately. |
## Payment attempts
Payment attempts allow you to track successful and failed payments, for both checkout and recurring charges.
Payment attempt events contain a `type`, which can be either `checkout` or `recurring`. You can use these values to determine whether a payment attempt was for a checkout or a subscription item renewal's recurring charge.
| Event Name | Description |
| - | - |
| `paymentAttempt.created` | A payment attempt has been created with `pending` status. It can either succeed or fail in the future. |
| `paymentAttempt.updated` | A payment attempt has been updated to `paid` or `failed` status. |
Looking for other webhook events? To find a list of all the events Clerk supports, navigate to the [**Webhooks**](https://dashboard.clerk.com/~/webhooks) page and select the **Event Catalog** tab.
---
title: Component Reference
description: A list of Clerk's comprehensive suite of components designed to
seamlessly integrate authentication and multi-tenancy into your application.
sdk: react, nextjs, js-frontend, chrome-extension, expo, android, expressjs,
fastify, react-router, remix, tanstack-react-start, go, astro, nuxt, vue,
ruby, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/overview
lastUpdated: 2025-11-21T23:29:30.000Z
availableSdks: react,nextjs,js-frontend,chrome-extension,expo,android,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
notAvailableSdks: ios
activeSdk: fastify
sourceFile: /docs/reference/components/overview.mdx
---
Clerk offers a comprehensive suite of components designed to seamlessly integrate authentication and multi-tenancy into your application. With Clerk components, you can easily customize the appearance of authentication components and pages, manage the entire authentication flow to suit your specific needs, and even build robust SaaS applications.
## Authentication components
* \
* \
* \
* \
* \
## User components
* \
* \
* \
## Organization components
* \
* \
* \
* \
## Billing components
* \
* \
* \
* \
## Control components
Control components manage authentication-related behaviors in your application. They handle tasks such as controlling content visibility based on user authentication status, managing loading states during authentication processes, and redirecting users to appropriate pages. Control components render at `` and `` states for assertions on the Clerk object. A common example is the \ component, which allows you to conditionally render content only when a user is authenticated.
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
## Unstyled components
* \
* \
* \
* \
## Customization guides
* [Customize components with the `appearance` prop](/docs/guides/customizing-clerk/appearance-prop/overview)
* [Localize components with the `localization` prop (experimental)](/docs/guides/customizing-clerk/localization)
* [Add pages to the `` component](/docs/guides/customizing-clerk/adding-items/user-profile)
* [Add pages to the `` component](/docs/guides/customizing-clerk/adding-items/organization-profile)
### Secured by Clerk branding
> \[!WARNING]
> This feature requires a [paid plan](/pricing){{ target: '_blank' }} for production use, but all features are free to use in development mode so that you can try out what works for you. See the [pricing](/pricing){{ target: '_blank' }} page for more information.
By default, Clerk displays a **Secured by Clerk** badge on Clerk components. You can remove this branding by following these steps:
1. In the Clerk Dashboard, navigate to your application's [**Settings**](https://dashboard.clerk.com/~/settings).
2. Under **Branding**, toggle on the **Remove "Secured by Clerk" branding** option.
* [Join our Discord](https://clerk.com/discord "Join Discord")
* Join our official Discord server to chat with us directly and become a part of the Clerk community.
* {}
***
* [Need help?](/support "Get help")
* Contact us through Discord, Twitter, or email to receive answers to your questions and learn more about Clerk.
* {}
---
title: Express Quickstart
description: Learn how to use Clerk to quickly and easily add secure
authentication and user management to your Express server.
sdk: nextjs, react, js-frontend, chrome-extension, expo, android, ios,
expressjs, fastify, react-router, remix, tanstack-react-start, go, astro,
nuxt, vue, ruby, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/getting-started/quickstart
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,react,js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
notAvailableSdks: ""
activeSdk: expressjs
sourceFile: /docs/getting-started/quickstart.expressjs.mdx
---
Learn how to integrate Clerk into your Express backend for secure user authentication and management. This guide focuses on backend implementation and requires a Clerk frontend SDK to function correctly.
## Install `@clerk/express`
The [Clerk Express SDK](/docs/reference/express/overview) provides a range of backend utilities to simplify user authentication and management in your application.
Run the following command to install the SDK:
```npm
npm install @clerk/express
```
## Set your Clerk API keys
Add the following keys to your `.env` file. These keys can always be retrieved from the [**API keys**](https://dashboard.clerk.com/~/api-keys) page in the Clerk Dashboard.
1. In the Clerk Dashboard, navigate to the [**API keys**](https://dashboard.clerk.com/~/api-keys) page.
2. In the **Quick Copy** section, copy your Clerk Publishable and Secret Keys.
3. Paste your keys into your `.env` file.
The final result should resemble the following:
```sh {{ filename: '.env' }}
CLERK_PUBLISHABLE_KEY={{pub_key}}
CLERK_SECRET_KEY={{secret}}
```
This guide uses `dotenv` to load the environment variables. Run the following command to install it:
```npm
npm install dotenv
```
## Add `clerkMiddleware()` to your app
The [`clerkMiddleware()`](/docs/reference/express/overview#clerk-middleware) function checks the request's cookies and headers for a session JWT and, if found, attaches the Auth{{ target: '_blank' }} object to the `request` object under the `auth` key.
```ts {{ filename: 'index.ts', mark: [3, 8] }}
import 'dotenv/config'
import express from 'express'
import { clerkMiddleware } from '@clerk/express'
const app = express()
const PORT = 3000
app.use(clerkMiddleware())
// Start the server and listen on the specified port
app.listen(PORT, () => {
console.log(`Example app listening at http://localhost:${PORT}`)
})
```
## Protect your routes using `requireAuth()`
To protect your routes, use the [`requireAuth()`](/docs/reference/express/overview#require-auth) middleware. This middleware functions similarly to `clerkMiddleware()`, but also protects your routes by redirecting unauthenticated users to the sign-in page.
In the following example, `requireAuth()` is used to protect the `/protected` route. If the user isn't authenticated, they're redirected to the homepage. If the user is authenticated, the [`getAuth()`](/docs/reference/express/overview#get-auth) function is used to get the `userId`, which is passed to clerkClient.users.getUser(){{ target: '_blank' }} to fetch the current user's `User` object.
```ts {{ filename: 'index.ts' }}
import 'dotenv/config'
import express from 'express'
import { clerkClient, requireAuth, getAuth } from '@clerk/express'
const app = express()
const PORT = 3000
// Use requireAuth() to protect this route
// If user isn't authenticated, requireAuth() will redirect back to the homepage
app.get('/protected', requireAuth(), async (req, res) => {
// Use `getAuth()` to get the user's `userId`
const { userId } = getAuth(req)
// Use Clerk's JS Backend SDK to get the user's User object
const user = await clerkClient.users.getUser(userId)
return res.json({ user })
})
// Start the server and listen on the specified port
app.listen(PORT, () => {
console.log(`Example app listening at http://localhost:${PORT}`)
})
```
## Add global TypeScript type (optional)
If you're using TypeScript, add a global type reference to your project to enable auto-completion and type checking for the `auth` object in Express request handlers.
1. In your application's root folder, create a `types/` directory.
2. Inside this directory, create a `globals.d.ts` file with the following code.
```ts {{ filename: 'types/globals.d.ts' }}
///
```
## Next steps
* [Use middleware to protect routes](/docs/reference/express/overview#require-auth)
* Learn how to protect specific routes from unauthenticated users.
***
* [Protect routes based on authorization status](/docs/reference/express/overview#get-auth)
* Learn how to protect a route based on both authentication and authorization status.
***
* [Express SDK reference](/docs/reference/express/overview)
* Learn more about additional Express SDK methods.
***
* [Deploy to Production](/docs/guides/development/deployment/production)
* Learn how to deploy your Clerk app to production.
---
title: Clerk Billing for B2C SaaS
description: Clerk Billing is a feature that allows you to create and manage
Plans and Features for your application.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/billing/for-b2c
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: expressjs
sourceFile: /docs/guides/billing/for-b2c.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing for B2C SaaS allows you to create Plans and manage Subscriptions **for individual users** in your application. If you'd like to charge companies or organizations, see Billing for B2B SaaS. You can also combine both B2C and B2B Billing in the same application.
## Enable Billing
To enable Billing for your application, navigate to the [**Billing Settings**](https://dashboard.clerk.com/~/billing/settings) page in the Clerk Dashboard. This page will guide you through enabling Billing for your application.
Clerk Billing costs the same as using Stripe Billing directly, just 0.7% per transaction, plus transaction fees which are paid directly to Stripe. Clerk Billing is **not** the same as Stripe Billing. Plans and pricing are managed directly through the Clerk Dashboard and won't sync with your existing Stripe products or plans. Clerk uses Stripe **only** for payment processing, so you don't need to set up Stripe Billing.
### Payment gateway
Once you have enabled Billing, you will see the following **Payment gateway** options for collecting payments via Stripe:
* **Clerk development gateway**: A shared **test** Stripe account used for development instances. This allows developers to test and build Billing flows **in development** without needing to create and configure a Stripe account.
* **Stripe account**: Use your own Stripe account for production. **A Stripe account created for a development instance cannot be used for production**. You will need to create a separate Stripe account for your production environment.
## Create a Plan
Subscription Plans are what your users subscribe to. There is no limit to the number of Plans you can create.
To create a Plan, navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard. Here, you can create, edit, and delete Plans. To setup B2C Billing, select the **Plans for Users** tab and select **Add Plan**. When creating a Plan, you can also create Features for the Plan; see the next section for more information.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's a user Plan, it can appear in the `` component. When creating or editing a Plan, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Add Features to a Plan
[Features](/docs/guides/secure/features) make it easy to give entitlements to your Plans. You can add any number of Features to a Plan.
You can add a Feature to a Plan when you are creating a Plan. To add it after a Plan is created:
1. Navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard.
2. Select the Plan you'd like to add a Feature to.
3. In the **Features** section, select **Add Feature**.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's a user Plan, it can appear in the `` component. When adding a Feature to a Plan, it will also automatically appear in the corresponding Plan. When creating or editing a Feature, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Create a pricing page
You can create a pricing page by using the \ component. This component displays a table of Plans and Features that users can subscribe to. **It's recommended to create a dedicated page**, as shown in the following example.
> \[!NOTE]
> To see an example of how to create a pricing table page, please select one of the frontend SDKs on the sidebar.
## Control access with Features and Plans
You can use Clerk's Features and Plans to gate access to the content. There are a few ways to do this, but the recommended approach is to either use the has() method or the \ component.
The `has()` method is available for any JavaScript framework, while `` is only available for React-based frameworks.
### Example: Using `has()`
Use the `has()` method to test if the user has access to a **Plan**:
```jsx
const hasPremiumAccess = has({ plan: 'gold' })
```
Or a **Feature**:
```jsx
const hasPremiumAccess = has({ feature: 'widgets' })
```
The has() method is a server-side helper that checks if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan) and returns a boolean value. `has()` is available on the auth object, which you will access differently depending on the framework you are using.
The following example demonstrates how to use `has()` to check if a user has a Plan.
```tsx {{ filename: 'src/routes/bronze-content.ts' }}
import { getAuth, requireAuth } from '@clerk/express'
import { Router } from 'express'
const router = Router()
router.get('/bronze-content', requireAuth(), async (req, res) => {
const { has } = getAuth(req)
const hasBronzePlan = has({ plan: 'bronze' })
if (hasBronzePlan) {
res.send('For Bronze subscribers only')
} else {
res.send('Only subscribers to the Bronze plan can access this content.')
}
})
export default router
```
The following example demonstrates how to use `has()` to check if a user has a Feature.
```ts {{ filename: 'src/routes/premium-content.ts' }}
import { getAuth, requireAuth } from '@clerk/express'
import { Router } from 'express'
const router = Router()
router.get('/premium-content', requireAuth(), async (req, res) => {
const { has } = getAuth(req)
const hasPremiumAccess = has({ feature: 'premium_access' })
if (!hasPremiumAccess) {
res.send('Only subscribers with the Premium Access feature can access this content.')
} else {
res.send('Our Exclusive Content')
}
})
export default router
```
### Example: Using ``
The \ component protects content or even entire routes by checking if the user has been granted a specific type of access control (Role, Permission, Feature, or Plan). You can pass a `fallback` prop to `` that will be rendered if the user does not have the access control.
The following example demonstrates how to use `` to protect a page by checking if the user has a Plan.
> \[!NOTE]
> To see an example of how to use the `Protect` component, please select one of the frontend SDKs on the sidebar.
The following example demonstrates how to use `` to protect a page by checking if the user has a Feature.
> \[!NOTE]
> To see an example of how to use the `Protect` component, please select one of the frontend SDKs on the sidebar.
---
title: Clerk Billing for B2B SaaS
description: Clerk Billing is a feature that allows you to create and manage
Plans and Features for your application.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/billing/for-b2b
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: expressjs
sourceFile: /docs/guides/billing/for-b2b.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing for B2B SaaS allows you to create Plans and manage Subscriptions **for companies or organizations** in your application. If you'd like to charge individual users, see Billing for B2C SaaS. You can also combine both B2C and B2B Billing in the same application.
## Enable Billing
To enable Billing for your application, navigate to the [**Billing Settings**](https://dashboard.clerk.com/~/billing/settings) page in the Clerk Dashboard. This page will guide you through enabling Billing for your application.
Clerk Billing costs the same as using Stripe Billing directly, just 0.7% per transaction, plus transaction fees which are paid directly to Stripe. Clerk Billing is **not** the same as Stripe Billing. Plans and pricing are managed directly through the Clerk Dashboard and won't sync with your existing Stripe products or plans. Clerk uses Stripe **only** for payment processing, so you don't need to set up Stripe Billing.
### Payment gateway
Once you have enabled Billing, you will see the following **Payment gateway** options for collecting payments via Stripe:
* **Clerk development gateway**: A shared **test** Stripe account used for development instances. This allows developers to test and build Billing flows **in development** without needing to create and configure a Stripe account.
* **Stripe account**: Use your own Stripe account for production. **A Stripe account created for a development instance cannot be used for production**. You will need to create a separate Stripe account for your production environment.
## Create a Plan
Subscription Plans are what your customers subscribe to. There is no limit to the number of Plans you can create. If your Clerk instance has existing [Custom Permissions](/docs/guides/organizations/roles-and-permissions), the corresponding Features from those Permissions will automatically be added to the free Plan for Orgs. This ensures that Organization members get the same set of Custom Permissions when Billing is enabled, because all Organizations start on the free Plan.
To create a Plan, navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard. Here, you can create, edit, and delete Plans. To setup B2B Billing, select the **Plans for Organizations** tab and select **Add Plan**. When creating a Plan, you can also create [Features](/docs/guides/secure/features) for the Plan; see the next section for more information.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's an Organization Plan, it can appear in the `` component. When creating or editing a Plan, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Add Features to a Plan
[Features](/docs/guides/secure/features) make it easy to give entitlements to your Plans. You can add any number of Features to a Plan.
You can add a Feature to a Plan when you are creating a Plan. To add it after a Plan is created:
1. Navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard.
2. Select the Plan you'd like to add a Feature to.
3. In the **Features** section, select **Add Feature**.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's an Organization Plan, it can appear in the `` component. When adding a Feature to a Plan, it will also automatically appear in the corresponding Plan. When creating or editing a Feature, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Create a pricing page
You can create a pricing page by using the \ component. This component displays a table of Plans and Features that customers can subscribe to. **It's recommended to create a dedicated page**, as shown in the following example.
> \[!NOTE]
> To see an example of how to create a pricing table page, please select one of the frontend SDKs on the sidebar.
## Control access with Features, Plans, and Permissions
You can use Clerk's Features, Plans, and Permissions to gate access to content using authorization checksAuthorization checks are checks you perform in your code to determine the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions or access certain content. Learn more about [authorization checks](/docs/guides/secure/authorization-checks).. There are a few ways to do this, but the recommended approach is to either use the has() method or the \ component.
The `has()` method is available for any JavaScript-based framework, while `` is a component, and therefore, is only available for React-based frameworks.
> \[!IMPORTANT]
> Permission-based authorization checks link with Feature-based authorization checks. This means that if you are checking a Custom Permission, it will only work if the Feature part of the Permission key (`org::`) **is a Feature included in the Organization's active Plan**. For example, say you want to check if an Organization member has the Custom Permission `org:teams:manage`, where `teams` is the Feature. Before performing the authorization check, you need to ensure that the user's Organization is subscribed to a Plan that has the `teams` Feature. If the user's Organization is not subscribed to a Plan that has the `teams` Feature, the authorization check will always return `false`, *even if the user has the Custom Permission*.
### Example: Using `has()`
Use the `has()` method to test if the Organization has access to a **Plan**:
```jsx
const hasPremiumAccess = has({ plan: 'gold' })
```
Or a **Feature**:
```jsx
const hasPremiumAccess = has({ feature: 'widgets' })
```
The has() method is a server-side helper that checks if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan) and returns a boolean value. `has()` is available on the auth object, which you will access differently depending on the framework you are using.
> \[!TIP]
> Why aren't Custom Permissions appearing in the session token (JWT) or in API responses (including the result of the `has()` check)?
>
> ***
>
> Custom Permissions will only appear in the session token (JWT) and in API responses (including the result of the `has()` check) if the Feature part of the Permission key (`org::`) **is a Feature included in the Organization's active Plan**. If the Feature is not part of the Plan, the `has()` check for Permissions using that Feature will return `false`, and those Permissions will not be represented in the session token.
>
> For example, say you want to check if an Organization member has the Custom Permission `org:teams:manage`, where `teams` is the Feature. The user's Organization must be subscribed to a Plan that has the `teams` Feature for authorization checks to work. If the user's Organization is not subscribed to a Plan that has the `teams` Feature, the authorization check will always return `false`, *even if the user has the Custom Permission*.
The following example demonstrates how to use `has()` to check if an Organization has a Plan.
```tsx {{ filename: 'src/routes/bronze-content.ts' }}
import { getAuth, requireAuth } from '@clerk/express'
import { Router } from 'express'
const router = Router()
router.get('/bronze-content', requireAuth(), async (req, res) => {
const { has } = getAuth(req)
const hasBronzePlan = has({ plan: 'bronze' })
if (hasBronzePlan) {
res.send('For Bronze subscribers only')
} else {
res.send('Only subscribers to the Bronze plan can access this content.')
}
})
export default router
```
The following example demonstrates how to use `has()` to check if an Organization has a Feature.
```ts {{ filename: 'src/routes/premium-content.ts' }}
import { getAuth, requireAuth } from '@clerk/express'
import { Router } from 'express'
const router = Router()
router.get('/premium-content', requireAuth(), async (req, res) => {
const { has } = getAuth(req)
const hasPremiumAccess = has({ feature: 'premium_access' })
if (!hasPremiumAccess) {
res.send('Only subscribers with the Premium Access feature can access this content.')
} else {
res.send('Our Exclusive Content')
}
})
export default router
```
The following example demonstrates how to use `has()` to check if an Organization has a Permission.
```tsx {{ filename: 'src/routes/manage-premium-content.ts' }}
import { getAuth, requireAuth } from '@clerk/express'
import { Router } from 'express'
const router = Router()
router.get('/manage-premium-content', requireAuth(), async (req, res) => {
const { has } = getAuth(req)
const hasPremiumAccessManage = has({ permission: 'org:premium_access:manage' })
if (hasPremiumAccessManage) {
res.send('Our Exclusive Content')
} else {
res.send('Only subscribers with the Premium Access Manage permission can access this content.')
}
})
export default router
```
### Example: Using ``
The \ component protects content or even entire routes by checking if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan). You can pass a `fallback` prop to `` that will be rendered if the Organization does not have the access control.
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Plan.
> \[!NOTE]
> To see an example of how to use the `Protect` component, please select one of the frontend SDKs on the sidebar.
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Feature.
> \[!NOTE]
> To see an example of how to use the `Protect` component, please select one of the frontend SDKs on the sidebar.
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Permission.
> \[!NOTE]
> To see an example of how to use the `Protect` component, please select one of the frontend SDKs on the sidebar.
---
title: Build an MCP server in your application with Clerk
description: Learn how to build an MCP server using Clerk's OAuth server in your
application.
sdk: nextjs, expressjs
sdkScoped: "true"
canonical: /docs/:sdk:/guides/development/mcp/build-mcp-server
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,expressjs
notAvailableSdks: react,js-frontend,chrome-extension,expo,android,ios,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
activeSdk: expressjs
sourceFile: /docs/guides/development/mcp/build-mcp-server.mdx
---
This guide demonstrates how to build an MCP server using Clerk's OAuth server in your Express app. It assumes that you have already integrated Clerk into your app by following the quickstart.
> \[!IMPORTANT]
> For most client implementations of MCP, [dynamic client registration](https://openid.net/specs/openid-connect-registration-1_0.html) is required. This allows MCP-compatible clients to automatically register themselves with your server during the OAuth flow.
> Before proceeding, ensure you have toggled on the **Dynamic client registration** option in the [OAuth Applications](https://dashboard.clerk.com/~/oauth-applications) page in the Clerk Dashboard.
## Install dependencies
To get started, this implementation requires the following packages to be installed in your project:
* [`@modelcontextprotocol/sdk`](https://github.com/modelcontextprotocol/typescript-sdk): Provides the core SDK for building an MCP server, including utilities to define tools and handle LLM requests.
* [`@clerk/mcp-tools`](https://github.com/clerk/mcp-tools): A helper library built on top of the [MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk) used to connect Clerk OAuth with MCP easily.
* [`cors`](https://github.com/expressjs/cors): Express middleware for handling CORS requests, which is needed for public clients to access your MCP server.
```npm
npm install @modelcontextprotocol/sdk @clerk/mcp-tools cors
```
## Set up your app with Clerk and MCP imports
The following code is the starting point for your MCP server. It includes the imports and setup needed to implement an MCP server with Clerk.
```ts {{ filename: 'index.ts' }}
import 'dotenv/config'
import { type MachineAuthObject, clerkClient, clerkMiddleware } from '@clerk/express'
import {
mcpAuthClerk,
protectedResourceHandlerClerk,
streamableHttpHandler,
} from '@clerk/mcp-tools/express'
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
import express from 'express'
import cors from 'cors'
const app = express()
// if you need to interface with a public client, this is required
app.use(cors({ exposedHeaders: ['WWW-Authenticate'] }))
app.use(clerkMiddleware())
app.use(express.json())
app.listen(3000)
```
## Create your MCP server and define tools
To let external LLM-powered tools securely interact with your app, you need to define an MCP server, and expose one or more [resources](https://modelcontextprotocol.io/docs/concepts/resources), [prompts](https://modelcontextprotocol.io/docs/concepts/prompts), and/or [tools](https://modelcontextprotocol.io/docs/concepts/tools).
For this guide, you'll implement a single, example tool called `get_clerk_user_data` that retrieves information about the authenticated Clerk user. For more documentation on how to build MCP tools, see the [MCP documentation](https://modelcontextprotocol.io/docs/concepts/tools).
The `McpServer()` function is used to create a new MCP server with a name and version. The `server.tool()` function is used to define tools that external LLM-based apps can invoke. Each tool includes:
* A name (`get-clerk-user-data`).
* A description of what the tool does.
* Input parameters (none in this case).
* A function that represents the implementation of the tool. In this case, it extracts the user ID, which is provided by Clerk's OAuth authentication, and then fetches the user's data using Clerk's getUser() method. The response is then returned in MCP's expected response format.
```ts {{ filename: 'index.ts', mark: [[15, 37]], collapsible: true }}
import 'dotenv/config'
import { type MachineAuthObject, clerkClient, clerkMiddleware } from '@clerk/express'
import {
mcpAuthClerk,
protectedResourceHandlerClerk,
streamableHttpHandler,
} from '@clerk/mcp-tools/express'
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
import express from 'express'
const app = express()
app.use(clerkMiddleware())
app.use(express.json())
const server = new McpServer({
name: 'test-server',
version: '0.0.1',
})
server.tool(
'get_clerk_user_data',
'Gets data about the Clerk user that authorized this request',
{},
async (_, { authInfo }) => {
// non-null assertion is safe here, mcpAuthClerk ensures presence
const userId = authInfo!.extra!.userId! as string
const userData = await clerkClient.users.getUser(userId)
return {
content: [{ type: 'text', text: JSON.stringify(userData) }],
}
},
)
app.listen(3000)
```
## Secure your MCP server & expose metadata endpoints
Now that your MCP server and tools are defined, the next step is to secure your endpoints and expose them according to the MCP specification. To comply with the MCP specification, your server must expose [OAuth protected resource metadata](https://datatracker.ietf.org/doc/html/rfc9728#section-4.1) at a specific endpoint (`.well-known/oauth-protected-resource`). This metadata allows clients to discover where to authenticate, and some details about how the authentication service works. Older versions of the MCP spec required that you also expose [OAuth authorization server metadata](https://datatracker.ietf.org/doc/html/rfc8414) at a specific endpoint (`.well-known/oauth-authorization-server`). This is no longer required by the current MCP spec, but it may be necessary for some clients that only support older versions of the spec.
Clerk provides prebuilt helpers via [`@clerk/mcp-tools`](https://github.com/clerk/mcp-tools) that handle this for you:
* `mcpAuthClerk`: Authentication middleware that automatically verifies the `Authorization` header using Clerk-issued OAuth tokens. If unauthorized, it returns a `www-authenticate` header [in accordance with the MCP specification](https://modelcontextprotocol.io/specification/2025-06-18/basic/authorization#authorization-server-location).
* `protectedResourceHandlerClerk`: Express handler that serves OAuth **protected resource metadata** in the format expected by MCP clients. This handler lets you define specific supported OAuth scopes to declare what access levels your resource requires.
* `authServerMetadataHandlerClerk`: Express handler that serves OAuth **authorization server metadata** in the format expected by MCP clients. This is still often needed for clients that implement older mcp spec versions.
* `streamableHttpHandler`: Express handler that connects your MCP server to incoming requests using the [streamable HTTP transport](https://modelcontextprotocol.io/docs/concepts/transports#streamable-http).
> \[!NOTE]
> For a more in-depth explanation of these helpers, see the [MCP Express reference](https://github.com/clerk/mcp-tools/tree/main/express).
To secure your endpoints and expose your MCP server to a client, add the following code to your file:
```ts {{ filename: 'index.ts', mark: [[3, 4]] }}
// The rest of your code...
app.post('/mcp', mcpAuthClerk, streamableHttpHandler(server))
app.get(
'/.well-known/oauth-protected-resource/mcp',
// Specify the scopes that your MCP server needs here
protectedResourceHandlerClerk({ scopes_supported: ['email', 'profile'] }),
)
// This is still often needed for clients that implement the older mcp spec
app.get('/.well-known/oauth-authorization-server', authServerMetadataHandlerClerk)
app.listen(3000)
```
> \[!WARNING]
> Your `.well-known` endpoints must be **publicly accessible** for MCP clients to discover OAuth metadata. When protecting routes, consider these paths and ensure they are not protected.
## Finished 🎉
Once this is complete, clients that support the latest MCP spec can now invoke the `get-clerk-user-data` tool to securely fetch user data from your app, assuming the request is authorized with a Clerk OAuth token. To test this out, [learn how to connect your client LLM to the MCP server](/docs/guides/development/mcp/connect-mcp-client).
The next step is to replace the demo tool with your own tools, resources, and/or prompts that are relevant to your app. You can learn more about how to do this in the [MCP SDK documentation](https://modelcontextprotocol.io/docs/concepts/tools).
---
title: Clerk Billing webhooks
description: Clerk Billing webhooks allow you to track subscription lifecycles
and monitor payment attempts.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/development/webhooks/billing
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: expressjs
sourceFile: /docs/guides/development/webhooks/billing.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing supports webhook events that allow you to track information like subscription lifecycles and payments.
## Subscriptions
A subscription is a top-level container unique to each user or organization. Subscription events can help you track billing changes for each of your customers.
| Event Name | Description |
| - | - |
| `subscription.created` | The top-level subscription is created. This usually happens when a user or organization is created. For existing users and organizations, a subscription will be created when Billing is enabled for the application. |
| `subscription.updated` | The top-level subscription is updated. This event is triggered when any property of the subscription has changed, except for status changes. For example, when the subscription items for the payer change. |
| `subscription.active` | The top-level subscription transitions to active from a non-active status. This happens when any subscription item is set to active, including items from the free default Plan. |
| `subscription.pastDue` | The top-level subscription contains a subscription item that has become past due. |
## Subscription items
A subscription item provides details about the relationship between the payer (user or Organization) and a Plan. A top-level subscription may contain multiple subscription items.
There can only be one `active` subscription item per payer and Plan. In addition, the subscription item for the default Plan will always have the same `id` to allow easier tracking of which users and Organizations are not paid customers.
| Event Name | Description |
| - | - |
| `subscriptionItem.updated` | The subscription item is updated. This event is triggered when a property of the subscription item has changed that does not result in a status change. For example, when a subscription item is renewed and the recurring monthly charge succeeds, the status doesn't change (remains `active`), but `period_start` and `period_end` are updated. This results in a `subscriptionItem.updated` event. |
| `subscriptionItem.active` | The subscription item is set to active. For paid Plans, this happens on successful payment. |
| `subscriptionItem.canceled` | The subscription item is canceled. The payer retains Plan features until the end of the current billing period. |
| `subscriptionItem.upcoming` | The subscription item is set as upcoming after the current billing period. This can happen in the case of a deferred Plan change from a higher-priced to lower-priced Plan. In the case a paid Plan is canceled, the subscription item for the default, free Plan will be set as `upcoming`. |
| `subscriptionItem.ended` | The subscription item has ended. |
| `subscriptionItem.abandoned` | The subscription item is abandoned. This can happen to `upcoming` subscription items if the payer subscribes to another Plan, or re-subscribes to a currently canceled Plan. |
| `subscriptionItem.incomplete` | The subscription item is incomplete. This means the payer has started a checkout for a Plan, but the payment hasn't been successfully processed yet. Once payment succeeds, the subscription item transitions to an `active` status. |
| `subscriptionItem.pastDue` | The subscription item is past due because a recurring charge has failed. |
| `subscriptionItem.freeTrialEnding` | The subscription item is a free trial and is ending soon. This event is sent three days before the trial ends. If the trial is shorter than three days, it's sent immediately. |
## Payment attempts
Payment attempts allow you to track successful and failed payments, for both checkout and recurring charges.
Payment attempt events contain a `type`, which can be either `checkout` or `recurring`. You can use these values to determine whether a payment attempt was for a checkout or a subscription item renewal's recurring charge.
| Event Name | Description |
| - | - |
| `paymentAttempt.created` | A payment attempt has been created with `pending` status. It can either succeed or fail in the future. |
| `paymentAttempt.updated` | A payment attempt has been updated to `paid` or `failed` status. |
Looking for other webhook events? To find a list of all the events Clerk supports, navigate to the [**Webhooks**](https://dashboard.clerk.com/~/webhooks) page and select the **Event Catalog** tab.
---
title: Component Reference
description: A list of Clerk's comprehensive suite of components designed to
seamlessly integrate authentication and multi-tenancy into your application.
sdk: react, nextjs, js-frontend, chrome-extension, expo, android, expressjs,
fastify, react-router, remix, tanstack-react-start, go, astro, nuxt, vue,
ruby, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/overview
lastUpdated: 2025-11-21T23:29:30.000Z
availableSdks: react,nextjs,js-frontend,chrome-extension,expo,android,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
notAvailableSdks: ios
activeSdk: expressjs
sourceFile: /docs/reference/components/overview.mdx
---
Clerk offers a comprehensive suite of components designed to seamlessly integrate authentication and multi-tenancy into your application. With Clerk components, you can easily customize the appearance of authentication components and pages, manage the entire authentication flow to suit your specific needs, and even build robust SaaS applications.
## Authentication components
* \
* \
* \
* \
* \
## User components
* \
* \
* \
## Organization components
* \
* \
* \
* \
## Billing components
* \
* \
* \
* \
## Control components
Control components manage authentication-related behaviors in your application. They handle tasks such as controlling content visibility based on user authentication status, managing loading states during authentication processes, and redirecting users to appropriate pages. Control components render at `` and `` states for assertions on the Clerk object. A common example is the \ component, which allows you to conditionally render content only when a user is authenticated.
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
## Unstyled components
* \
* \
* \
* \
## Customization guides
* [Customize components with the `appearance` prop](/docs/guides/customizing-clerk/appearance-prop/overview)
* [Localize components with the `localization` prop (experimental)](/docs/guides/customizing-clerk/localization)
* [Add pages to the `` component](/docs/guides/customizing-clerk/adding-items/user-profile)
* [Add pages to the `` component](/docs/guides/customizing-clerk/adding-items/organization-profile)
### Secured by Clerk branding
> \[!WARNING]
> This feature requires a [paid plan](/pricing){{ target: '_blank' }} for production use, but all features are free to use in development mode so that you can try out what works for you. See the [pricing](/pricing){{ target: '_blank' }} page for more information.
By default, Clerk displays a **Secured by Clerk** badge on Clerk components. You can remove this branding by following these steps:
1. In the Clerk Dashboard, navigate to your application's [**Settings**](https://dashboard.clerk.com/~/settings).
2. Under **Branding**, toggle on the **Remove "Secured by Clerk" branding** option.
* [Join our Discord](https://clerk.com/discord "Join Discord")
* Join our official Discord server to chat with us directly and become a part of the Clerk community.
* {}
***
* [Need help?](/support "Get help")
* Contact us through Discord, Twitter, or email to receive answers to your questions and learn more about Clerk.
* {}
---
title: Sign in with Apple
description: Learn how to use Clerk to natively Sign in with Apple.
sdk: ios, expo
sdkScoped: "true"
canonical: /docs/:sdk:/guides/configure/auth-strategies/sign-in-with-apple
lastUpdated: 2025-11-21T22:25:46.000Z
availableSdks: ios,expo
notAvailableSdks: nextjs,react,js-frontend,chrome-extension,android,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
activeSdk: ios
sourceFile: /docs/guides/configure/auth-strategies/sign-in-with-apple.mdx
---
This guide will teach you how to add native [Sign in with Apple](https://developer.apple.com/sign-in-with-apple/) to your Clerk apps on Apple platforms.
> \[!NOTE]
> Apple Sign-In works on both iOS Simulators and physical devices. However, physical devices provide full functionality including biometric authentication (Face ID/Touch ID), while simulators have limited support. Always test on a physical device before releasing to production.
## Add your Native Application
Add your iOS application to the [**Native Applications**](https://dashboard.clerk.com/~/native-applications) page in the Clerk dashboard. You will need your iOS app's **App ID Prefix** and **Bundle ID**.
## Enable Apple as a social connection
1. In the Clerk Dashboard, navigate to the [**SSO Connections**](https://dashboard.clerk.com/~/user-authentication/sso-connections) page.
2. Select **Add connection** and select **For all users**.
3. In the **Choose provider** dropdown, select **Apple**.
4. Ensure that **Enable for sign-up and sign-in** is toggled on.
> \[!NOTE]
> Apple provides a privacy feature called [Hide My Email](https://support.apple.com/en-us/HT210425#hideemail), allowing users to sign in to your app with Apple without disclosing their actual email addresses. Instead, your instance receives an app-specific email address that forwards any emails to the user's real address. To be able to send emails properly to users with hidden addresses, you must configure an additional setting in the Apple Developer portal. See [Configure Email Source for Apple Private Relay](/docs/guides/configure/auth-strategies/social-connections/apple#configure-email-source-for-apple-private-relay){{ target: '_blank' }} for more information.
## Add the Sign in with Apple capability to your app
[Add the Sign in with Apple capability to your app](https://developer.apple.com/documentation/xcode/configuring-sign-in-with-apple#Add-the-Sign-in-with-Apple-capability-to-your-app).
> \[!NOTE]
> If you are using Clerk's prebuilt components, you don't need to do anything else and can stop here. The `SignInWithApple` button will appear in your `AuthView` automatically.
> If you are building a custom flowA **custom flow** refers to a user interface built entirely from scratch using the Clerk API. Learn more about [custom flows](/docs/guides/development/custom-flows/overview)., continue to follow the steps below.
## Obtain an Apple ID Credential
To authenticate with Apple and Clerk, you need to obtain an [Apple ID Credential](https://developer.apple.com/documentation/authenticationservices/asauthorizationappleidcredential).
To obtain an Apple ID Credential, you can do one of the following:
* Use one of [Apple's built-in Sign in with Apple buttons](https://developer.apple.com/documentation/signinwithapple/displaying-sign-in-with-apple-buttons-in-your-app).
* Use Clerk's [`SignInWithAppleHelper`](https://swiftpackageindex.com/clerk/clerk-ios/main/documentation/clerk/signinwithapplehelper) class.
* Obtain it manually by following [the Apple docs](https://developer.apple.com/documentation/signinwithapple).
> \[!NOTE]
> You must set the nonce property of the `ASAuthorizationAppleIDRequest` when requesting an Apple ID Credential in order to authenticate with Clerk.
## Build your sign-in flow
Once you have obtained your [Apple ID Credential](https://developer.apple.com/documentation/authenticationservices/asauthorizationappleidcredential), you can use it to authenticate with Clerk by calling [`SignIn.authenticateWithIdToken(provider:idToken:)`](https://swiftpackageindex.com/clerk/clerk-ios/main/documentation/clerk/signin/authenticatewithidtoken\(provider:idtoken:\)) with a provider of `.apple` and the `idToken` you have obtained.
The following example uses Apple's built-in `SignInWithAppleButton` to obtain an Apple ID Credential and calls `SignIn.authenticateWithIdToken(provider:idToken:)` to authenticate with Clerk.
```swift {{ filename: 'SignInWithAppleView.swift' }}
import SwiftUI
import Clerk
import AuthenticationServices
struct SignInWithAppleView: View {
var body: some View {
// Use Apple's built-in SignInWithAppleButton
SignInWithAppleButton { request in
request.requestedScopes = [.email, .fullName]
request.nonce = UUID().uuidString // Setting the nonce is mandatory
} onCompletion: { result in
Task {
// Access the Apple ID Credential
guard let credential = try result.get().credential as? ASAuthorizationAppleIDCredential else {
dump("Unable to get credential of type ASAuthorizationAppleIDCredential")
return
}
// Access the necessary identity token on the Apple ID Credential
guard let idToken = credential.identityToken.flatMap({ String(data: $0, encoding: .utf8) }) else {
dump("Unable to get ID token from Apple ID Credential.")
return
}
// Authenticate with Clerk
let authResult = try await SignIn.authenticateWithIdToken(provider: .apple, idToken: idToken)
}
}
}
}
```
---
title: iOS Quickstart
description: Add authentication and user management to your iOS app with Clerk.
sdk: nextjs, react, js-frontend, chrome-extension, expo, android, ios,
expressjs, fastify, react-router, remix, tanstack-react-start, go, astro,
nuxt, vue, ruby, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/getting-started/quickstart
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,react,js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
notAvailableSdks: ""
activeSdk: ios
sourceFile: /docs/getting-started/quickstart.ios.mdx
---
## Enable Native API
In the Clerk Dashboard, navigate to the [**Native Applications**](https://dashboard.clerk.com/~/native-applications) page and ensure that the Native API is enabled. This is required to integrate Clerk in your native application.
## Create an iOS Project
To get started using Clerk with iOS, create a new project in Xcode. Select SwiftUI as your interface and Swift as your language.
See the [Xcode documentation](https://developer.apple.com/documentation/xcode/creating-an-xcode-project-for-an-app) for more information.
## Install the Clerk iOS SDK
Follow [the Swift Package Manager instructions](https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app) to install Clerk as a dependency.
When prompted for the package URL, enter `https://github.com/clerk/clerk-ios`. Be sure to add the package to your target.
## Add your Native Application
Add your iOS application to the [**Native Applications**](https://dashboard.clerk.com/~/native-applications) page in the Clerk Dashboard. You will need your iOS app's **App ID Prefix** and **Bundle ID**.
## Add associated domain capability
To enable seamless authentication flows, you need to add an associated domain capability to your iOS app. This allows your app to work with Clerk's authentication services.
1. In Xcode, select your project in the Project Navigator.
2. Select your app target.
3. Navigate to the **Signing & Capabilities** tab.
4. Select the **+ Capability** option.
5. Search for and add **Associated Domains**. It will be added as a dropdown to the **Signing & Capabilities** tab.
6. Under **Associated Domains**, add a new entry with the value: `webcredentials:{YOUR_FRONTEND_API_URL}`
> \[!NOTE]
> Replace `{YOUR_FRONTEND_API_URL}` with your Frontend API URL, which can be found on the [**Native Applications**](https://dashboard.clerk.com/~/native-applications) page in the Clerk Dashboard.
## Load Clerk
To use Clerk in your app, you must first configure and load `Clerk`.
1. Inside your new project in Xcode, open your `@main` app file.
2. Import `Clerk`.
3. Create a reference to the shared `Clerk` instance.
4. Inject the `clerk` instance into the SwiftUI environment using `.environment(\.clerk, clerk)` so your views can access it.
5. Add a `.task` modifier that configures Clerk with your Clerk Publishable Key and loads it when the app starts.You can retrieve your Publishable Key from the [**API keys**](https://dashboard.clerk.com/~/api-keys) page in the Clerk Dashboard.
```swift {{ filename: 'ClerkQuickstartApp.swift', mark: [2, 6, [11, 15]] }}
import SwiftUI
import Clerk
@main
struct ClerkQuickstartApp: App {
@State private var clerk = Clerk.shared
var body: some Scene {
WindowGroup {
ContentView()
.environment(\.clerk, clerk)
.task {
clerk.configure(publishableKey: "{{pub_key}}")
try? await clerk.load()
}
}
}
}
```
## Conditionally render content
To render content based on whether a user is authenticated or not:
1. Open your `ContentView` file.
2. Import `Clerk` and access the shared `Clerk` instance that you injected into the environment in the previous step.
3. Replace the content of the view body with a conditional that checks for a `clerk.user`.
```swift {{ filename: 'ContentView.swift', mark: [2, 5, [8, 14]] }}
import SwiftUI
import Clerk
struct ContentView: View {
@Environment(\.clerk) private var clerk
var body: some View {
VStack {
if let user = clerk.user {
Text("Hello, \(user.firstName ?? "User")")
} else {
Text("You are signed out")
}
}
}
}
```
## Use Clerk's prebuilt views
Clerk provides prebuilt SwiftUI views that handle authentication flows and user management, eliminating the need to build custom forms and flows.
Update your `ContentView` to use Clerk's prebuilt views. Replace the existing content with the following code:
```swift {{ filename: 'ContentView.swift', mark: [2, 5, 6, [9, 21]] }}
import SwiftUI
import Clerk
struct ContentView: View {
@Environment(\.clerk) private var clerk
@State private var authIsPresented = false
var body: some View {
VStack {
if clerk.user != nil {
UserButton()
.frame(width: 36, height: 36)
} else {
Button("Sign in") {
authIsPresented = true
}
}
}
.sheet(isPresented: $authIsPresented) {
AuthView()
}
}
}
```
The updated `ContentView` uses two key Clerk views:
* [`AuthView`](/docs/reference/views/authentication/auth-view): A comprehensive authentication view that handles sign-in and sign-up flows, including email verification, password reset, and multi-factor authentication. It's presented as a sheet when the user taps "Sign in".
* [`UserButton`](/docs/reference/views/user/user-button): A circular button that displays the user's profile image. When tapped, it automatically presents the [`UserProfileView`](/docs/reference/views/user/user-profile-view) where users can manage their account, update their profile, and sign out.
## Create your first user
Run your project. When you tap "Sign in", the `AuthView` will appear, allowing you to sign up or sign in.
---
title: Android Quickstart
description: Add authentication and user management to your Android app with Clerk.
sdk: nextjs, react, js-frontend, chrome-extension, expo, android, ios,
expressjs, fastify, react-router, remix, tanstack-react-start, go, astro,
nuxt, vue, ruby, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/getting-started/quickstart
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,react,js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
notAvailableSdks: ""
activeSdk: android
sourceFile: /docs/getting-started/quickstart.android.mdx
---
## Enable Native API
In the Clerk Dashboard, navigate to the [**Native Applications**](https://dashboard.clerk.com/~/native-applications) page and ensure that the Native API is enabled. This is required to integrate Clerk in your native application.
## Create an Android Project
1. Create a new Android project in Android Studio using the **Empty Activity** template. This tutorial uses `MyClerkApp` as the app name. If you choose a different name, be sure to update any code examples accordingly to match your app's name.
2. Open the `app/build.gradle.kts` file and ensure that your project's minimum SDK version is set to 24 or higher, and that your project's Java version is set to 17 or higher, as these are the minimum requirements for the Clerk Android SDK.
3. In `app/build.gradle.kts`, add the following libraries to your `dependencies` block:
* The [Clerk Android SDK](/docs/reference/android/overview). Check the [GitHub release page](https://github.com/clerk/clerk-android/releases) for the latest version.
* [Android's Lifecycle ViewModel Compose library](https://developer.android.com/reference/kotlin/androidx/lifecycle/viewmodel/compose/package-summary).
```gradle
dependencies {
...
implementation("com.clerk:clerk-android:")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.9.2")
...
}
```
4. Sync your project to apply the changes after adding the dependencies.
## Initialize Clerk
In `app/src/main/java/com/example/myclerkapp/`, create a Kotlin class named `MyClerkApp`. Add the following code to:
1. Create a subclass of `Application` named after your application (e.g., `MyClerkApp`).
2. In this subclass, override the `onCreate()` method and call `Clerk.initialize()` to initialize the Clerk Android SDK with your application context (`this`) and Clerk Publishable Key. Your Publishable Key can always be retrieved from the [**API keys**](https://dashboard.clerk.com/~/api-keys) page in the Clerk Dashboard.
1. Create a subclass of `Application` named after your application (e.g., `MyClerkApp`).
2. In this subclass, override the `onCreate()` method and call `Clerk.initialize()` to initialize the Clerk Android SDK with your application context (`this`) and Clerk Publishable Key.
To find your Publishable Key:
1. In the Clerk Dashboard, navigate to the [**API keys**](https://dashboard.clerk.com/~/api-keys) page.
2. Copy your Clerk Publishable Key. It's prefixed with `pk_test_` for development instances and `pk_live_` for production instances.
```kotlin {{ filename: 'app/src/main/java/com/example/myclerkapp/MyClerkApp.kt' }}
package com.example.myclerkapp
import android.app.Application
import com.clerk.api.Clerk
class MyClerkApp: Application() {
override fun onCreate() {
super.onCreate()
Clerk.initialize(
this,
publishableKey = {{pub_key}}
)
}
}
```
## Configure the `AndroidManifest.xml`
In `app/src/main/AndroidManifest.xml`, add the following configuration:
1. Inside the root `` tag, add the following line to enable internet permission on your Android device.
```xml
...
```
2. Inside the `` tag, add the following line to use the `MyClerkApp` class as the entry point for app-level configuration.
```xml
...
```
## Listen for SDK initialization and authentication events
Let's start building out your home page.
In your `app/src/main/java/com/example/myclerkapp/` directory, create a Kotlin class named `MainViewModel` with the following code. `MainViewModel` is a `ViewModel` that sets the state as `Loading` when the Clerk SDK is initializing, `SignedIn` when the user is signed in, or `SignedOut` when the user is signed out. The Clerk SDK initialization is non-blocking. Therefore, it's recommended to listen for the SDK to emit a success from Clerk's `isInitialized` global object to know when it's ready to use.
```kotlin {{ filename: 'app/src/main/java/com/example/myclerkapp/MainViewModel.kt', collapsible: true }}
package com.example.myclerkapp
import android.util.Log
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.clerk.api.Clerk
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.launchIn
class MainViewModel: ViewModel() {
private val _uiState = MutableStateFlow(MainUiState.Loading)
val uiState = _uiState.asStateFlow()
init {
combine(Clerk.isInitialized, Clerk.userFlow) { isInitialized, user ->
_uiState.value = when {
!isInitialized -> MainUiState.Loading
user != null -> MainUiState.SignedIn
else -> MainUiState.SignedOut
}
}
.launchIn(viewModelScope)
}
}
sealed interface MainUiState {
data object Loading : MainUiState
data object SignedIn : MainUiState
data object SignedOut : MainUiState
}
```
## Conditionally render content
Now that you're listening for initialization and authentication events, set up your UI to react to them. In your `MainActivity.kt`, add the following code. This will show a loading indicator while the Clerk SDK is initializing, and a signed in or signed out experience based on the user's authentication state.
```kotlin {{ filename: 'app/src/main/java/com/example/myclerkapp/MainActivity.kt', collapsible: true }}
package com.example.myclerkapp
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.runtime.getValue
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Text
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.lifecycle.compose.collectAsStateWithLifecycle
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
val viewModel: MainViewModel by viewModels()
val state by viewModel.uiState.collectAsStateWithLifecycle()
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
when (state) {
MainUiState.Loading -> CircularProgressIndicator()
MainUiState.SignedOut -> Text("You're signed out")
MainUiState.SignedIn -> Text("You're signed in")
}
}
}
}
}
```
## Create sign-up and sign-in views
### Sign-up view
Create a Kotlin class named `SignUpViewModel` with the following code. It allows users to sign up using their email address and password, and sends an email verification code to confirm their email address.
```kotlin {{ filename: 'app/src/main/java/com/example/myclerkapp/SignUpViewModel.kt', collapsible: true }}
package com.example.myclerkapp
import android.util.Log
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.clerk.api.Clerk
import com.clerk.api.network.serialization.longErrorMessageOrNull
import com.clerk.api.network.serialization.onFailure
import com.clerk.api.network.serialization.onSuccess
import com.clerk.api.signup.SignUp
import com.clerk.api.signup.attemptVerification
import com.clerk.api.signup.prepareVerification
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
class SignUpViewModel : ViewModel() {
private val _uiState = MutableStateFlow(SignUpUiState.SignedOut)
val uiState = _uiState.asStateFlow()
fun signUp(email: String, password: String) {
viewModelScope.launch {
SignUp.create(SignUp.CreateParams.Standard(emailAddress = email, password = password))
.onSuccess {
if (it.status == SignUp.Status.COMPLETE) {
_uiState.value = SignUpUiState.Success
} else {
_uiState.value = SignUpUiState.NeedsVerification
it.prepareVerification(SignUp.PrepareVerificationParams.Strategy.EmailCode())
}
}
.onFailure {
// See https://clerk.com/docs/guides/development/custom-flows/error-handling
// for more info on error handling
Log.e("SignUpViewModel", it.longErrorMessageOrNull, it.throwable)
}
}
}
fun verify(code: String) {
val inProgressSignUp = Clerk.signUp ?: return
viewModelScope.launch {
inProgressSignUp.attemptVerification(SignUp.AttemptVerificationParams.EmailCode(code))
.onSuccess { _uiState.value = SignUpUiState.Success }
.onFailure {
// See https://clerk.com/docs/guides/development/custom-flows/error-handling
// for more info on error handling
Log.e("SignUpViewModel", it.longErrorMessageOrNull, it.throwable)
}
}
}
sealed interface SignUpUiState {
data object SignedOut : SignUpUiState
data object Success : SignUpUiState
data object NeedsVerification : SignUpUiState
}
}
```
Then, create a `SignUpView` file with the following code to use the `SignUpViewModel`.
```kotlin {{ filename: 'app/src/main/java/com/example/myclerkapp/SignUpView.kt', collapsible: true }}
package com.example.myclerkapp
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
@Composable
fun SignUpView(viewModel: SignUpViewModel = viewModel()) {
val state by viewModel.uiState.collectAsState()
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(24.dp, Alignment.CenterVertically)
) {
Text("Sign Up")
if (state is SignUpViewModel.SignUpUiState.NeedsVerification) {
var code by remember { mutableStateOf("") }
TextField(value = code, onValueChange = { code = it })
Button(onClick = { viewModel.verify(code) }) { Text("Verify") }
} else {
var email by remember { mutableStateOf("") }
var password by remember { mutableStateOf("") }
TextField(value = email, onValueChange = { email = it }, placeholder = { Text("Email") })
TextField(
value = password,
placeholder = { Text("Password") },
onValueChange = { password = it },
visualTransformation = PasswordVisualTransformation(),
)
Button(onClick = { viewModel.signUp(email, password) }) { Text("Sign Up") }
}
}
}
```
### Sign-in view
Create a Kotlin class named `SignInViewModel` with the following code. It allows users to sign in using their email address and password.
```kotlin {{ filename: 'app/src/main/java/com/example/myclerkapp/SignInViewModel.kt', collapsible: true }}
package com.example.myclerkapp
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.clerk.api.network.serialization.onFailure
import com.clerk.api.network.serialization.onSuccess
import com.clerk.api.signin.SignIn
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
class SignInViewModel : ViewModel() {
private val _uiState = MutableStateFlow(SignInUiState.Idle)
val uiState = _uiState.asStateFlow()
fun signIn(email: String, password: String) {
viewModelScope.launch {
SignIn.create(SignIn.CreateParams.Strategy.Password(identifier = email, password = password))
.onSuccess { _uiState.value = SignInUiState.Success }
.onFailure { _uiState.value = SignInUiState.Error }
}
}
sealed interface SignInUiState {
data object Idle : SignInUiState
data object Error : SignInUiState
data object Success : SignInUiState
}
}
```
Then, create a `SignInView` file with the following code to use the `SignInViewModel`.
```kotlin {{ filename: 'app/src/main/java/com/example/myclerkapp/SignInView.kt', collapsible: true }}
package com.example.myclerkapp
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
@Composable
fun SignInView(viewModel: SignInViewModel = viewModel()) {
var email by remember { mutableStateOf("") }
var password by remember { mutableStateOf("") }
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(24.dp, Alignment.CenterVertically)
) {
Text("Sign In")
TextField(value = email, onValueChange = { email = it }, placeholder = { Text("Email") })
TextField(
value = password,
onValueChange = { password = it },
placeholder = { Text("password") },
visualTransformation = PasswordVisualTransformation(),
)
Button(onClick = { viewModel.signIn(email, password) }) { Text("Sign In") }
}
}
```
### Combine the views
Commonly, authentication flows will allow users to switch between sign up and sign in, such as a "Already signed up? Sign in" button. To add this to your app, create a `SignInOrUpView` file with the following code. This container view combines the `SignUpView` and `SignInView`, and allows users to switch between them.
```kotlin {{ filename: 'app/src/main/java/com/example/myclerkapp/SignInOrUpView.kt', collapsible: true }}
package com.example.myclerkapp
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
@Composable
fun SignInOrUpView() {
var isSignUp by remember { mutableStateOf(true) }
Column(
modifier = Modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(24.dp, Alignment.CenterVertically),
) {
if (isSignUp) {
SignUpView()
} else {
SignInView()
}
Button(onClick = { isSignUp = !isSignUp }) {
if (isSignUp) {
Text("Already have an account? Sign in")
} else {
Text("Don't have an account? Sign up")
}
}
}
}
```
Then, in your `MainActivity` file, render your newly created `SignInOrUpView` when the user isn't signed in.
```kotlin {{ filename: 'app/src/main/java/com/example/myclerkapp/MainActivity.kt', mark: [31] }}
package com.example.myclerkapp
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.runtime.getValue
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Text
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.lifecycle.compose.collectAsStateWithLifecycle
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
val viewModel: MainViewModel by viewModels()
val state by viewModel.uiState.collectAsStateWithLifecycle()
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
when (state) {
MainUiState.Loading -> CircularProgressIndicator()
MainUiState.SignedOut -> SignInOrUpView()
MainUiState.SignedIn -> Text("You're signed in")
}
}
}
}
}
```
## Allow users to sign out
Finally, provide users with a way to sign out of your app.
In your `MainViewModel`, add a `signOut` function that calls `Clerk.signOut()`.
```kotlin {{ filename: 'app/src/main/java/com/example/myclerkapp/MainViewModel.kt', mark: [14, [7, 9], [31, 41]], collapsible: true }}
package com.example.myclerkapp
import android.util.Log
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.clerk.api.Clerk
import com.clerk.api.network.serialization.longErrorMessageOrNull
import com.clerk.api.network.serialization.onFailure
import com.clerk.api.network.serialization.onSuccess
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.launch
class MainViewModel: ViewModel() {
private val _uiState = MutableStateFlow(MainUiState.Loading)
val uiState = _uiState.asStateFlow()
init {
combine(Clerk.isInitialized, Clerk.userFlow) { isInitialized, user ->
_uiState.value = when {
!isInitialized -> MainUiState.Loading
user != null -> MainUiState.SignedIn
else -> MainUiState.SignedOut
}
}
.launchIn(viewModelScope)
}
fun signOut() {
viewModelScope.launch() {
Clerk.signOut()
.onSuccess { _uiState.value = MainUiState.SignedOut }
.onFailure {
// See https://clerk.com/docs/guides/development/custom-flows/error-handling
// for more info on error handling
Log.e("MainViewModel", it.longErrorMessageOrNull, it.throwable)
}
}
}
}
sealed interface MainUiState {
data object Loading : MainUiState
data object SignedIn : MainUiState
data object SignedOut : MainUiState
}
```
Then, in your `MainActivity`, add a button that calls the `signOut` function when clicked.
```kotlin {{ filename: 'app/src/main/java/com/example/myclerkapp/MainActivity.kt', mark: [10, 33], collapsible: true }}
package com.example.myclerkapp
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.runtime.getValue
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Button
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Text
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.lifecycle.compose.collectAsStateWithLifecycle
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
val viewModel: MainViewModel by viewModels()
val state by viewModel.uiState.collectAsStateWithLifecycle()
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
when (state) {
MainUiState.Loading -> CircularProgressIndicator()
MainUiState.SignedOut -> SignInOrUpView()
MainUiState.SignedIn -> Button(onClick = { viewModel.signOut() }) { Text("Sign out") }
}
}
}
}
}
```
## Create your first user
Run your project and sign up to create your first user.
---
title: Component Reference
description: A list of Clerk's comprehensive suite of components designed to
seamlessly integrate authentication and multi-tenancy into your application.
sdk: react, nextjs, js-frontend, chrome-extension, expo, android, expressjs,
fastify, react-router, remix, tanstack-react-start, go, astro, nuxt, vue,
ruby, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/reference/components/overview
lastUpdated: 2025-11-21T23:29:30.000Z
availableSdks: react,nextjs,js-frontend,chrome-extension,expo,android,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
notAvailableSdks: ios
activeSdk: android
sourceFile: /docs/reference/components/overview.mdx
---
Clerk offers a comprehensive suite of components designed to seamlessly integrate authentication and multi-tenancy into your application. With Clerk components, you can easily customize the appearance of authentication components and pages, manage the entire authentication flow to suit your specific needs, and even build robust SaaS applications.
## Authentication components
* \
* \
* \
* \
* \
## User components
* \
* \
* \
## Organization components
* \
* \
* \
* \
## Billing components
* \
* \
* \
* \
## Control components
Control components manage authentication-related behaviors in your application. They handle tasks such as controlling content visibility based on user authentication status, managing loading states during authentication processes, and redirecting users to appropriate pages. Control components render at `` and `` states for assertions on the Clerk object. A common example is the \ component, which allows you to conditionally render content only when a user is authenticated.
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
* \
## Unstyled components
* \
* \
* \
* \
## Customization guides
* [Customize components with the `appearance` prop](/docs/guides/customizing-clerk/appearance-prop/overview)
* [Localize components with the `localization` prop (experimental)](/docs/guides/customizing-clerk/localization)
* [Add pages to the `` component](/docs/guides/customizing-clerk/adding-items/user-profile)
* [Add pages to the `` component](/docs/guides/customizing-clerk/adding-items/organization-profile)
### Secured by Clerk branding
> \[!WARNING]
> This feature requires a [paid plan](/pricing){{ target: '_blank' }} for production use, but all features are free to use in development mode so that you can try out what works for you. See the [pricing](/pricing){{ target: '_blank' }} page for more information.
By default, Clerk displays a **Secured by Clerk** badge on Clerk components. You can remove this branding by following these steps:
1. In the Clerk Dashboard, navigate to your application's [**Settings**](https://dashboard.clerk.com/~/settings).
2. Under **Branding**, toggle on the **Remove "Secured by Clerk" branding** option.
* [Join our Discord](https://clerk.com/discord "Join Discord")
* Join our official Discord server to chat with us directly and become a part of the Clerk community.
* {}
***
* [Need help?](/support "Get help")
* Contact us through Discord, Twitter, or email to receive answers to your questions and learn more about Clerk.
* {}
---
title: Expo Quickstart
description: Add authentication and user management to your Expo app with Clerk.
sdk: nextjs, react, js-frontend, chrome-extension, expo, android, ios,
expressjs, fastify, react-router, remix, tanstack-react-start, go, astro,
nuxt, vue, ruby, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/getting-started/quickstart
lastUpdated: 2025-11-19T22:57:21.000Z
availableSdks: nextjs,react,js-frontend,chrome-extension,expo,android,ios,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
notAvailableSdks: ""
activeSdk: expo
sourceFile: /docs/getting-started/quickstart.expo.mdx
---
## Enable Native API
In the Clerk Dashboard, navigate to the [**Native Applications**](https://dashboard.clerk.com/~/native-applications) page and ensure that the Native API is enabled. This is required to integrate Clerk in your native application.
## Install `@clerk/clerk-expo`
The [Clerk Expo SDK](/docs/reference/expo/overview) gives you access to prebuilt components, hooks, and helpers to make user authentication easier.
Run the following command to install the SDK:
```npm
npm install @clerk/clerk-expo
```
## Set your Clerk API keys
Add your Clerk Publishable Key to your `.env` file. It can always be retrieved from the [**API keys**](https://dashboard.clerk.com/~/api-keys) page in the Clerk Dashboard.
1. In the Clerk Dashboard, navigate to the [**API keys**](https://dashboard.clerk.com/~/api-keys) page.
2. In the **Quick Copy** section, copy your Clerk Publishable Key.
3. Paste your key into your `.env` file.
The final result should resemble the following:
```env {{ filename: '.env' }}
EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY={{pub_key}}
```
## Add `` to your root layout
The \ component provides session and user context to Clerk's hooks and components. It's recommended to wrap your entire app at the entry point with `` to make authentication globally accessible. See the reference docs for other configuration options.
Add the component to your root layout as shown in the following example:
```tsx {{ filename: 'app/_layout.tsx', mark: [1, 6, 8] }}
import { ClerkProvider } from '@clerk/clerk-expo'
import { Slot } from 'expo-router'
export default function RootLayout() {
return (
)
}
```
## Configure the token cache
Clerk stores the active user's session token in memory by default. In Expo apps, the recommended way to store sensitive data, such as tokens, is by using `expo-secure-store` which encrypts the data before storing it.
To use `expo-secure-store` as your token cache:
1. Run the following command to install the library:
```npm
npm install expo-secure-store
```
2. Update your root layout to use the secure token cache:
```tsx {{ filename: 'app/_layout.tsx', mark: [2, 7] }}
import { ClerkProvider } from '@clerk/clerk-expo'
import { tokenCache } from '@clerk/clerk-expo/token-cache'
import { Slot } from 'expo-router'
export default function RootLayout() {
return (
)
}
```
> \[!TIP]
> When you sign a user out with signOut(), Clerk will remove the user's session JWT from the token cache.
## Add sign-up and sign-in pages
Clerk currently only supports control components for Expo native. UI components are only available for Expo web. Instead, you must build custom flowsA **custom flow** refers to a user interface built entirely from scratch using the Clerk API. Learn more about [custom flows](/docs/guides/development/custom-flows/overview). using Clerk's API. The following sections demonstrate how to build [custom email/password sign-up and sign-in flows](/docs/guides/development/custom-flows/authentication/email-password). If you want to use different authentication methods, such as passwordless or OAuth, see the dedicated custom flow guides.
### Layout page
First, protect your sign-up and sign-in pages.
1. Create an `(auth)` [route group](https://docs.expo.dev/router/advanced/shared-routes/). This will group your sign-up and sign-in pages.
2. In the `(auth)` group, create a `_layout.tsx` file with the following code. The useAuth() hook is used to access the user's authentication state. If the user is already signed in, they will be redirected to the home page.
```tsx {{ filename: 'app/(auth)/_layout.tsx' }}
import { Redirect, Stack } from 'expo-router'
import { useAuth } from '@clerk/clerk-expo'
export default function AuthRoutesLayout() {
const { isSignedIn } = useAuth()
if (isSignedIn) {
return
}
return
}
```
### Sign-up page
In the `(auth)` group, create a `sign-up.tsx` file with the following code. The useSignUp() hook is used to create a sign-up flow. The user can sign up using their email and password and will receive an email verification code to confirm their email.
```tsx {{ filename: 'app/(auth)/sign-up.tsx', collapsible: true }}
import * as React from 'react'
import { Text, TextInput, TouchableOpacity, View } from 'react-native'
import { useSignUp } from '@clerk/clerk-expo'
import { Link, useRouter } from 'expo-router'
export default function SignUpScreen() {
const { isLoaded, signUp, setActive } = useSignUp()
const router = useRouter()
const [emailAddress, setEmailAddress] = React.useState('')
const [password, setPassword] = React.useState('')
const [pendingVerification, setPendingVerification] = React.useState(false)
const [code, setCode] = React.useState('')
// Handle submission of sign-up form
const onSignUpPress = async () => {
if (!isLoaded) return
console.log(emailAddress, password)
// Start sign-up process using email and password provided
try {
await signUp.create({
emailAddress,
password,
})
// Send user an email with verification code
await signUp.prepareEmailAddressVerification({ strategy: 'email_code' })
// Set 'pendingVerification' to true to display second form
// and capture OTP code
setPendingVerification(true)
} catch (err) {
// See https://clerk.com/docs/guides/development/custom-flows/error-handling
// for more info on error handling
console.error(JSON.stringify(err, null, 2))
}
}
// Handle submission of verification form
const onVerifyPress = async () => {
if (!isLoaded) return
try {
// Use the code the user provided to attempt verification
const signUpAttempt = await signUp.attemptEmailAddressVerification({
code,
})
// If verification was completed, set the session to active
// and redirect the user
if (signUpAttempt.status === 'complete') {
await setActive({ session: signUpAttempt.createdSessionId })
router.replace('/')
} else {
// If the status is not complete, check why. User may need to
// complete further steps.
console.error(JSON.stringify(signUpAttempt, null, 2))
}
} catch (err) {
// See https://clerk.com/docs/guides/development/custom-flows/error-handling
// for more info on error handling
console.error(JSON.stringify(err, null, 2))
}
}
if (pendingVerification) {
return (
<>
Verify your email setCode(code)}
/>
Verify
>
)
}
return (
<>
Sign up setEmailAddress(email)}
/>
setPassword(password)}
/>
ContinueAlready have an account?Sign in
>
)
}
```
### Sign-in page
In the `(auth)` group, create a `sign-in.tsx` file with the following code. The useSignIn() hook is used to create a sign-in flow. The user can sign in using email address and password, or navigate to the sign-up page.
```tsx {{ filename: 'app/(auth)/sign-in.tsx', collapsible: true }}
import { useSignIn } from '@clerk/clerk-expo'
import { Link, useRouter } from 'expo-router'
import { Text, TextInput, TouchableOpacity, View } from 'react-native'
import React from 'react'
export default function Page() {
const { signIn, setActive, isLoaded } = useSignIn()
const router = useRouter()
const [emailAddress, setEmailAddress] = React.useState('')
const [password, setPassword] = React.useState('')
// Handle the submission of the sign-in form
const onSignInPress = async () => {
if (!isLoaded) return
// Start the sign-in process using the email and password provided
try {
const signInAttempt = await signIn.create({
identifier: emailAddress,
password,
})
// If sign-in process is complete, set the created session as active
// and redirect the user
if (signInAttempt.status === 'complete') {
await setActive({ session: signInAttempt.createdSessionId })
router.replace('/')
} else {
// If the status isn't complete, check why. User might need to
// complete further steps.
console.error(JSON.stringify(signInAttempt, null, 2))
}
} catch (err) {
// See https://clerk.com/docs/guides/development/custom-flows/error-handling
// for more info on error handling
console.error(JSON.stringify(err, null, 2))
}
}
return (
Sign in setEmailAddress(emailAddress)}
/>
setPassword(password)}
/>
ContinueDon't have an account?Sign up
)
}
```
For more information about building these custom flowsA **custom flow** refers to a user interface built entirely from scratch using the Clerk API. Learn more about [custom flows](/docs/guides/development/custom-flows/overview)., including guided comments in the code examples, see the [Build a custom email/password authentication flow](/docs/guides/development/custom-flows/authentication/email-password) guide.
## Add a sign-out button
At this point, your users can sign up or in, but they need a way to sign out.
In the `components/` folder, create a `SignOutButton.tsx` file with the following code. The useClerk() hook is used to access the `signOut()` function, which is called when the user clicks the "Sign out" button.
```tsx {{ filename: 'app/components/SignOutButton.tsx', collapsible: true }}
import { useClerk } from '@clerk/clerk-expo'
import { useRouter } from 'expo-router'
import { Text, TouchableOpacity } from 'react-native'
export const SignOutButton = () => {
// Use `useClerk()` to access the `signOut()` function
const { signOut } = useClerk()
const router = useRouter()
const handleSignOut = async () => {
try {
await signOut()
// Redirect to your desired page
router.replace('/')
} catch (err) {
// See https://clerk.com/docs/guides/development/custom-flows/error-handling
// for more info on error handling
console.error(JSON.stringify(err, null, 2))
}
}
return (
Sign out
)
}
```
## Conditionally render content
You can control which content signed-in and signed-out users can see with Clerk's prebuilt control components. For this quickstart, you'll use:
* \: Children of this component can only be seen while **signed in**.
* \: Children of this component can only be seen while **signed out**.
To get started:
1. Create a `(home)` route group.
2. In the `(home)` group, create a `_layout.tsx` file with the following code.
```tsx {{ filename: 'app/(home)/_layout.tsx' }}
import { Stack } from 'expo-router/stack'
export default function Layout() {
return
}
```
Then, in the same folder, create an `index.tsx` file with the following code. If the user is signed in, it displays their email and a sign-out button. If they're not signed in, it displays sign-in and sign-up links.
```tsx {{ filename: 'app/(home)/index.tsx' }}
import { SignedIn, SignedOut, useUser } from '@clerk/clerk-expo'
import { Link } from 'expo-router'
import { Text, View } from 'react-native'
import { SignOutButton } from '@/app/components/SignOutButton'
export default function Page() {
const { user } = useUser()
return (
Hello {user?.emailAddresses[0].emailAddress}Sign inSign up
)
}
```
## Create your first user
Run your project with the following command:
```bash {{ filename: 'terminal' }}
npm start
```
```bash {{ filename: 'terminal' }}
yarn start
```
```bash {{ filename: 'terminal' }}
pnpm start
```
```bash {{ filename: 'terminal' }}
bun start
```
Now visit your app's homepage at [`http://localhost:8081`](http://localhost:8081). Sign up to create your first user.
## Enable OTA updates
Though not required, it is recommended to implement over-the-air (OTA) updates in your Expo app. This enables you to easily roll out Clerk's feature updates and security patches as they're released without having to resubmit your app to mobile marketplaces.
See the [`expo-updates`](https://docs.expo.dev/versions/latest/sdk/updates) library to learn how to get started.
## Next steps
* [SSO with Expo](/docs/guides/development/custom-flows/authentication/oauth-connections)
* Learn more how to build a custom OAuth flow with Expo.
***
* [MFA with Expo](/docs/guides/development/custom-flows/authentication/email-password-mfa)
* Learn more how to build a custom multi-factor authentication flow with Expo.
***
* [Protect content and read user data](/docs/expo/guides/users/reading)
* Learn how to use Clerk's hooks and helpers to protect content and read user data in your Expo app.
***
* [Sign-up and sign-in flow](/docs/guides/development/custom-flows/authentication/email-password)
* Learn how to build a custom sign-up and sign-in authentication flow.
---
title: Sign in with Apple
description: Learn how to use Clerk to natively Sign in with Apple in your Expo app.
sdk: ios, expo
sdkScoped: "true"
canonical: /docs/:sdk:/guides/configure/auth-strategies/sign-in-with-apple
lastUpdated: 2025-11-21T22:25:46.000Z
availableSdks: ios,expo
notAvailableSdks: nextjs,react,js-frontend,chrome-extension,android,expressjs,fastify,react-router,remix,tanstack-react-start,go,astro,nuxt,vue,ruby,js-backend
activeSdk: expo
sourceFile: /docs/guides/configure/auth-strategies/sign-in-with-apple.expo.mdx
---
This guide will teach you how to add native [Sign in with Apple](https://developer.apple.com/sign-in-with-apple/) to your Clerk Expo application.
> \[!NOTE]
> Apple Sign-In works on both iOS Simulators and physical devices. However, physical devices provide full functionality including biometric authentication (Face ID/Touch ID), while simulators have limited support. Always test on a physical device before releasing to production.
## Add your Native Application
Add your iOS application to the [**Native Applications**](https://dashboard.clerk.com/last-active?path=native-applications) page in the Clerk Dashboard. You will need your iOS app's **App ID Prefix** (Team ID) and **Bundle ID**.
## Enable Apple as a social connection
1. In the Clerk Dashboard, navigate to the [**SSO Connections**](https://dashboard.clerk.com/last-active?path=user-authentication/sso-connections) page.
2. Select **Add connection** and select **For all users**.
3. In the **Choose provider** dropdown, select **Apple**.
4. Ensure that **Enable for sign-up and sign-in** is toggled on.
> \[!NOTE]
> Apple provides a privacy feature called [Hide My Email](https://support.apple.com/en-us/HT210425#hideemail), allowing users to sign in to your app with Apple without disclosing their actual email addresses. Instead, your instance receives an app-specific email address that forwards any emails to the user's real address. To be able to send emails properly to users with hidden addresses, you must configure an additional setting in the Apple Developer portal. See [Configure Email Source for Apple Private Relay](/docs/guides/configure/auth-strategies/social-connections/apple#configure-email-source-for-apple-private-relay){{ target: '_blank' }} for more information.
## Install dependencies
The [Expo Apple Authentication library](https://docs.expo.dev/versions/latest/sdk/apple-authentication/) provides access to Apple's native Sign in with Apple functionality from your Expo app.
Run the following command to install the library:
```npm {{ filename: 'terminal' }}
npx expo install expo-apple-authentication
```
## Add `expo-apple-authentication` to your app config
Add the `expo-apple-authentication` plugin to your `app.json` or `app.config.js`.
```json {{ filename: 'app.json' }}
{
"expo": {
"plugins": ["expo-apple-authentication"]
}
}
```
```js {{ filename: 'app.config.js' }}
export default {
expo: {
plugins: ['expo-apple-authentication'],
},
}
```
## Build your authentication flow
The following example demonstrates how to use the [`useSignInWithApple()`](/docs/reference/expo/use-sign-in-with-apple) hook to manage the Apple authentication flow. Because the `useSignInWithApple()` hook automatically manages the transfer flowA **transfer flow** allows a user to both sign in and sign up in the same process. If a user tries signing up, but already exists, the flow will transfer the user to the sign-in flow. If a user tries signing in, but doesn't exist, the flow will transfer the user to the sign-up flow. between sign-up and sign-in, you can use this component for both your sign-up and sign-in pages.
```tsx {{ filename: 'components/AppleSignInButton.tsx', collapsible: true }}
import { useSignInWithApple } from '@clerk/clerk-expo'
import { useRouter } from 'expo-router'
import { Alert, Platform, StyleSheet, Text, TouchableOpacity, View } from 'react-native'
// Example props that you could pass to your button
interface AppleSignInButtonProps {
// Callback function that is called when the sign-in is complete
onSignInComplete?: () => void
// Whether to show a divider between the button and the text
showDivider?: boolean
}
export function AppleSignInButton({
onSignInComplete,
showDivider = true,
}: AppleSignInButtonProps) {
const { startAppleAuthenticationFlow } = useSignInWithApple()
const router = useRouter()
// Only render on iOS
if (Platform.OS !== 'ios') {
return null
}
const handleAppleSignIn = async () => {
try {
const { createdSessionId, setActive } = await startAppleAuthenticationFlow()
if (createdSessionId && setActive) {
// Set the created session as the active session
await setActive({ session: createdSessionId })
// Once the session is set as active,
// if a callback function is provided, call it.
// Otherwise, redirect to the home page.
onSignInComplete ? onSignInComplete() : router.replace('/')
}
} catch (err: any) {
// User canceled the sign-in flow
if (err.code === 'ERR_REQUEST_CANCELED') return
Alert.alert('Error', err.message || 'An error occurred during Apple Sign-In')
console.error('Apple Sign-In error:', JSON.stringify(err, null, 2))
}
}
return (
<>
Sign in with Apple
{showDivider && (
OR
)}
>
)
}
const styles = StyleSheet.create({
appleButton: {
backgroundColor: '#000',
padding: 15,
borderRadius: 8,
alignItems: 'center',
marginBottom: 10,
},
appleButtonText: {
color: '#fff',
fontSize: 16,
fontWeight: '600',
},
divider: {
flexDirection: 'row',
alignItems: 'center',
marginVertical: 20,
},
dividerLine: {
flex: 1,
height: 1,
backgroundColor: '#ccc',
},
dividerText: {
marginHorizontal: 10,
color: '#666',
},
})
```
## Create a native build
Create a native build with EAS Build or a local prebuild, since Apple Authentication is not supported in Expo Go.
```bash {{ filename: 'terminal' }}
# Using EAS Build
eas build --platform ios
# Or using local prebuild
npx expo prebuild && npx expo run:ios --device
```
---
title: Clerk Billing for B2C SaaS
description: Clerk Billing is a feature that allows you to create and manage
Plans and Features for your application.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/billing/for-b2c
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: expo
sourceFile: /docs/guides/billing/for-b2c.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing for B2C SaaS allows you to create Plans and manage Subscriptions **for individual users** in your application. If you'd like to charge companies or organizations, see Billing for B2B SaaS. You can also combine both B2C and B2B Billing in the same application.
## Enable Billing
To enable Billing for your application, navigate to the [**Billing Settings**](https://dashboard.clerk.com/~/billing/settings) page in the Clerk Dashboard. This page will guide you through enabling Billing for your application.
Clerk Billing costs the same as using Stripe Billing directly, just 0.7% per transaction, plus transaction fees which are paid directly to Stripe. Clerk Billing is **not** the same as Stripe Billing. Plans and pricing are managed directly through the Clerk Dashboard and won't sync with your existing Stripe products or plans. Clerk uses Stripe **only** for payment processing, so you don't need to set up Stripe Billing.
### Payment gateway
Once you have enabled Billing, you will see the following **Payment gateway** options for collecting payments via Stripe:
* **Clerk development gateway**: A shared **test** Stripe account used for development instances. This allows developers to test and build Billing flows **in development** without needing to create and configure a Stripe account.
* **Stripe account**: Use your own Stripe account for production. **A Stripe account created for a development instance cannot be used for production**. You will need to create a separate Stripe account for your production environment.
## Create a Plan
Subscription Plans are what your users subscribe to. There is no limit to the number of Plans you can create.
To create a Plan, navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard. Here, you can create, edit, and delete Plans. To setup B2C Billing, select the **Plans for Users** tab and select **Add Plan**. When creating a Plan, you can also create Features for the Plan; see the next section for more information.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's a user Plan, it can appear in the `` component. When creating or editing a Plan, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Add Features to a Plan
[Features](/docs/guides/secure/features) make it easy to give entitlements to your Plans. You can add any number of Features to a Plan.
You can add a Feature to a Plan when you are creating a Plan. To add it after a Plan is created:
1. Navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard.
2. Select the Plan you'd like to add a Feature to.
3. In the **Features** section, select **Add Feature**.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's a user Plan, it can appear in the `` component. When adding a Feature to a Plan, it will also automatically appear in the corresponding Plan. When creating or editing a Feature, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Create a pricing page
You can create a pricing page by using the \ component. This component displays a table of Plans and Features that users can subscribe to. **It's recommended to create a dedicated page**, as shown in the following example.
> \[!NOTE]
> Expo only supports the `` component on the **web**.
```tsx {{ filename: 'app/(home)/pricing.tsx' }}
import { PricingTable } from '@clerk/clerk-expo/web'
import { View } from 'react-native'
export default function PricingPage() {
return (
)
}
```
## Control access with Features and Plans
You can use Clerk's Features and Plans to gate access to the content. There are a few ways to do this, but the recommended approach is to either use the has() method or the \ component.
The `has()` method is available for any JavaScript framework, while `` is only available for React-based frameworks.
### Example: Using `has()`
Use the `has()` method to test if the user has access to a **Plan**:
```jsx
const hasPremiumAccess = has({ plan: 'gold' })
```
Or a **Feature**:
```jsx
const hasPremiumAccess = has({ feature: 'widgets' })
```
The has() method is a server-side helper that checks if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan) and returns a boolean value. `has()` is available on the auth object, which you will access differently depending on the framework you are using.
The following example demonstrates how to use `has()` to check if a user has a Plan.
```tsx {{ filename: 'app/(home)/bronze-content.tsx' }}
import { useAuth } from '@clerk/clerk-expo'
import { Text } from 'react-native'
export default function BronzeContentPage() {
const { isLoaded, has } = useAuth()
if (!isLoaded) return
Loading...
const hasBronzePlan = has({ plan: 'bronze' })
if (!hasBronzePlan)
return Only subscribers to the Bronze plan can access this content.
return For Bronze subscribers only
}
```
The following example demonstrates how to use `has()` to check if a user has a Feature.
```tsx {{ filename: 'app/(home)/premium-content.tsx' }}
import { useAuth } from '@clerk/clerk-expo'
import { Text } from 'react-native'
export default function PremiumContentPage() {
const { isLoaded, has } = useAuth()
if (!isLoaded) return
Loading...
const hasPremiumAccess = has({ feature: 'premium_access' })
if (!hasPremiumAccess)
return Only subscribers with the Premium Access feature can access this content.
return Our Exclusive Content
}
```
### Example: Using ``
The \ component protects content or even entire routes by checking if the user has been granted a specific type of access control (Role, Permission, Feature, or Plan). You can pass a `fallback` prop to `` that will be rendered if the user does not have the access control.
The following example demonstrates how to use `` to protect a page by checking if the user has a Plan.
```tsx {{ filename: 'app/(home)/protected-content.tsx' }}
import { Protect } from '@clerk/clerk-expo'
import { Text } from 'react-native'
export default function ProtectedContentPage() {
return (
Only subscribers to the Bronze plan can access this content.}
>
Exclusive Bronze ContentThis content is only visible to Bronze subscribers.
)
}
```
The following example demonstrates how to use `` to protect a page by checking if the user has a Feature.
```tsx {{ filename: 'app/(home)/protected-premium-content.tsx' }}
import { Protect } from '@clerk/clerk-expo'
import { Text, View } from 'react-native'
export default function ProtectedPremiumContentPage() {
return (
Only subscribers with the Premium Access feature can access this content.
}
>
Exclusive Premium ContentThis content is only visible to users with Premium Access feature.
)
}
```
---
title: Clerk Billing for B2B SaaS
description: Clerk Billing is a feature that allows you to create and manage
Plans and Features for your application.
sdk: nextjs, react, expo, react-router, astro, tanstack-react-start, remix,
nuxt, vue, js-frontend, expressjs, fastify, js-backend
sdkScoped: "true"
canonical: /docs/:sdk:/guides/billing/for-b2b
lastUpdated: 2025-11-21T22:00:50.000Z
availableSdks: nextjs,react,expo,react-router,astro,tanstack-react-start,remix,nuxt,vue,js-frontend,expressjs,fastify,js-backend
notAvailableSdks: chrome-extension,android,ios,go,ruby
activeSdk: expo
sourceFile: /docs/guides/billing/for-b2b.mdx
---
> \[!WARNING]
>
> Billing is currently in Beta and its APIs are experimental and may undergo breaking changes. To mitigate potential disruptions, we recommend [pinning](/docs/pinning) your SDK and `clerk-js` package versions.
Clerk Billing for B2B SaaS allows you to create Plans and manage Subscriptions **for companies or organizations** in your application. If you'd like to charge individual users, see Billing for B2C SaaS. You can also combine both B2C and B2B Billing in the same application.
## Enable Billing
To enable Billing for your application, navigate to the [**Billing Settings**](https://dashboard.clerk.com/~/billing/settings) page in the Clerk Dashboard. This page will guide you through enabling Billing for your application.
Clerk Billing costs the same as using Stripe Billing directly, just 0.7% per transaction, plus transaction fees which are paid directly to Stripe. Clerk Billing is **not** the same as Stripe Billing. Plans and pricing are managed directly through the Clerk Dashboard and won't sync with your existing Stripe products or plans. Clerk uses Stripe **only** for payment processing, so you don't need to set up Stripe Billing.
### Payment gateway
Once you have enabled Billing, you will see the following **Payment gateway** options for collecting payments via Stripe:
* **Clerk development gateway**: A shared **test** Stripe account used for development instances. This allows developers to test and build Billing flows **in development** without needing to create and configure a Stripe account.
* **Stripe account**: Use your own Stripe account for production. **A Stripe account created for a development instance cannot be used for production**. You will need to create a separate Stripe account for your production environment.
## Create a Plan
Subscription Plans are what your customers subscribe to. There is no limit to the number of Plans you can create. If your Clerk instance has existing [Custom Permissions](/docs/guides/organizations/roles-and-permissions), the corresponding Features from those Permissions will automatically be added to the free Plan for Orgs. This ensures that Organization members get the same set of Custom Permissions when Billing is enabled, because all Organizations start on the free Plan.
To create a Plan, navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard. Here, you can create, edit, and delete Plans. To setup B2B Billing, select the **Plans for Organizations** tab and select **Add Plan**. When creating a Plan, you can also create [Features](/docs/guides/secure/features) for the Plan; see the next section for more information.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's an Organization Plan, it can appear in the `` component. When creating or editing a Plan, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Add Features to a Plan
[Features](/docs/guides/secure/features) make it easy to give entitlements to your Plans. You can add any number of Features to a Plan.
You can add a Feature to a Plan when you are creating a Plan. To add it after a Plan is created:
1. Navigate to the [**Plans**](https://dashboard.clerk.com/~/billing/plans) page in the Clerk Dashboard.
2. Select the Plan you'd like to add a Feature to.
3. In the **Features** section, select **Add Feature**.
> \[!TIP]
> What is the **Publicly available** option?
>
> ***
>
> Plans appear in some Clerk components depending on what kind of Plan it is. All Plans can appear in the `` component. If it's an Organization Plan, it can appear in the `` component. When adding a Feature to a Plan, it will also automatically appear in the corresponding Plan. When creating or editing a Feature, if you'd like to hide it from appearing in Clerk components, you can toggle the **Publicly available** option off.
## Create a pricing page
You can create a pricing page by using the \ component. This component displays a table of Plans and Features that customers can subscribe to. **It's recommended to create a dedicated page**, as shown in the following example.
> \[!NOTE]
> Expo only supports the `` component on the **web**.
```tsx {{ filename: 'app/(home)/pricing.tsx' }}
import { PricingTable } from '@clerk/clerk-expo/web'
import { View } from 'react-native'
export default function PricingPage() {
return (
)
}
```
## Control access with Features, Plans, and Permissions
You can use Clerk's Features, Plans, and Permissions to gate access to content using authorization checksAuthorization checks are checks you perform in your code to determine the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions or access certain content. Learn more about [authorization checks](/docs/guides/secure/authorization-checks).. There are a few ways to do this, but the recommended approach is to either use the has() method or the \ component.
The `has()` method is available for any JavaScript-based framework, while `` is a component, and therefore, is only available for React-based frameworks.
> \[!IMPORTANT]
> Permission-based authorization checks link with Feature-based authorization checks. This means that if you are checking a Custom Permission, it will only work if the Feature part of the Permission key (`org::`) **is a Feature included in the Organization's active Plan**. For example, say you want to check if an Organization member has the Custom Permission `org:teams:manage`, where `teams` is the Feature. Before performing the authorization check, you need to ensure that the user's Organization is subscribed to a Plan that has the `teams` Feature. If the user's Organization is not subscribed to a Plan that has the `teams` Feature, the authorization check will always return `false`, *even if the user has the Custom Permission*.
### Example: Using `has()`
Use the `has()` method to test if the Organization has access to a **Plan**:
```jsx
const hasPremiumAccess = has({ plan: 'gold' })
```
Or a **Feature**:
```jsx
const hasPremiumAccess = has({ feature: 'widgets' })
```
The has() method is a server-side helper that checks if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan) and returns a boolean value. `has()` is available on the auth object, which you will access differently depending on the framework you are using.
> \[!TIP]
> Why aren't Custom Permissions appearing in the session token (JWT) or in API responses (including the result of the `has()` check)?
>
> ***
>
> Custom Permissions will only appear in the session token (JWT) and in API responses (including the result of the `has()` check) if the Feature part of the Permission key (`org::`) **is a Feature included in the Organization's active Plan**. If the Feature is not part of the Plan, the `has()` check for Permissions using that Feature will return `false`, and those Permissions will not be represented in the session token.
>
> For example, say you want to check if an Organization member has the Custom Permission `org:teams:manage`, where `teams` is the Feature. The user's Organization must be subscribed to a Plan that has the `teams` Feature for authorization checks to work. If the user's Organization is not subscribed to a Plan that has the `teams` Feature, the authorization check will always return `false`, *even if the user has the Custom Permission*.
The following example demonstrates how to use `has()` to check if an Organization has a Plan.
```tsx {{ filename: 'app/(home)/bronze-content.tsx' }}
import { useAuth } from '@clerk/clerk-expo'
import { Text } from 'react-native'
export default function BronzeContentPage() {
const { isLoaded, has } = useAuth()
if (!isLoaded) return
Loading...
const hasBronzePlan = has({ plan: 'bronze' })
if (!hasBronzePlan)
return Only subscribers to the Bronze plan can access this content.
return For Bronze subscribers only
}
```
The following example demonstrates how to use `has()` to check if an Organization has a Feature.
```tsx {{ filename: 'app/(home)/premium-content.tsx' }}
import { useAuth } from '@clerk/clerk-expo'
import { Text } from 'react-native'
export default function PremiumContentPage() {
const { isLoaded, has } = useAuth()
if (!isLoaded) return
Loading...
const hasPremiumAccess = has({ feature: 'premium_access' })
if (!hasPremiumAccess)
return Only subscribers with the Premium Access feature can access this content.
return Our Exclusive Content
}
```
The following example demonstrates how to use `has()` to check if an Organization has a Permission.
```tsx {{ filename: 'app/(home)/manage-premium-content.tsx' }}
import { useAuth } from '@clerk/clerk-expo'
import { Text } from 'react-native'
export default function ManagePremiumContentPage() {
const { isLoaded, has } = useAuth()
if (!isLoaded) return
Loading...
const hasPremiumAccessManage = has({ permission: 'org:premium_access:manage' })
if (!hasPremiumAccessManage)
return (
Only subscribers with the Premium Access Manage permission can access this content.
)
return Our Exclusive Content
}
```
### Example: Using ``
The \ component protects content or even entire routes by checking if the Organization has been granted a specific type of access control (Role, Permission, Feature, or Plan). You can pass a `fallback` prop to `` that will be rendered if the Organization does not have the access control.
The following example demonstrates how to use `` to protect a page by checking if the Organization has a Plan.
```tsx {{ filename: 'app/(home)/protected-content.tsx' }}
import { Protect } from '@clerk/clerk-expo'
import { Text } from 'react-native'
export default function ProtectedContentPage() {
return (
Only subscribers to the Bronze plan can access this content.}
>