Compute the destination after a custom sign-in flow
Custom authentication UI
Clerk · Pipe
buildAfterSignInUrl() returns the Clerk-configured full URL or path for navigation after successful sign-in or sign-up. The legacy afterSignInUrl setting is deprecated in favor of current redirect configuration options.
buildAfterSignInUrl() reads the Clerk instance configuration and produces the full URL or path intended for navigation after a successful sign-in or sign-up. The optional params object can provide URL search parameters when constructing the result.
function buildAfterSignInUrl(params?: { params?: URLSearchParams }): string| Name | Type | Description |
|---|---|---|
params | { params?: URLSearchParams } | Optional options object; its params property supplies URL search parameters used when building the destination. |
A string containing the configured full URL or path for after-sign-in navigation.
afterSignInUrl configuration is deprecated in the current stable guidance; use the sign-in fallback or force-redirect configuration instead.redirect_url query parameter.const destination = Clerk.buildAfterSignInUrl();
window.location.assign(destination);Builds the configured destination and navigates the browser there after sign-in.
Custom authentication UI
Redirect handling
Migration
buildAfterSignInUrl() do?It returns the configured full URL or path used after a successful sign-in or sign-up. The method signature accepts an optional object containing URL search parameters.
Follow-up: How would you preserve an incoming redirect? Use the redirect-aware sign-in configuration and let the incoming redirect_url take precedence when the fallback behavior is selected.
Its signature is function buildAfterSignInUrl(params?: { params?: URLSearchParams }): string. It returns a string suitable for navigation.
Follow-up: Why might the result be a path rather than an absolute URL? Clerk documents the setting as accepting either a full URL or a path.
afterSignInUrl still the recommended configuration?The legacy afterSignInUrl prop and corresponding environment variable are deprecated. Current configuration should use the sign-in fallback or force-redirect alternatives.
Follow-up: When is fallback preferable? Choose fallback when an existing redirect should be honored and the configured destination should apply only when no redirect is present.
buildSignInUrlredirectToAfterSignInsignInFallbackRedirectUrlsignInForceRedirectUrlredirectUrl