Custom Flow Reference (Clerk Android API)
Use this file only when flow type is custom.
Purpose
Implement native Android auth with Clerk API primitives while preserving Clerk's multi-step auth semantics and dashboard-driven capability gating.
Source-Driven Requirements
Use current clerk-android source/docs as primary references:
source/apifor sign-in/sign-up/session/auth APIs.source/ui/authandsamples/custom-flowsfor flow sequencing patterns.- Android quickstart for required project setup.
Source priority rules for custom flow:
- Primary source: Clerk Android API and auth flow source.
- Secondary source:
samples/custom-flows. - Fallback only: high-level docs when behavior is unclear from SDK/source.
Required Patterns
- Artifact selection
- Ensure
com.clerk:clerk-android-apiis installed. - Do not add
clerk-android-uiunless developer explicitly asks for a hybrid prebuilt/custom approach.
- Quickstart prerequisite audit
- Read the official Android quickstart:
https://clerk.com/docs/android/getting-started/quickstart. - Verify required project setup (Native API, min SDK/Java, manifest internet permission, app-level initialization).
- Implement missing required setup before finishing custom auth work.
- Initialization and state contract
- Initialize via
Clerk.initialize(...)at app startup. - Wait for
Clerk.isInitializedbefore treating Clerk as ready. - Drive session/user UI from
Clerk.userFlow/Clerk.sessionFlow.
- Capability-driven flow logic
- Use Clerk runtime capability/settings fields to drive flow branches (first factors, social providers, MFA, Google One Tap support).
- Do not hardcode fixed factor/provider assumptions.
- Multi-step flow progression
- Keep sign-in/sign-up progression split into explicit steps/states.
- Avoid collapsing all required auth input into one monolithic screen.
- Keep branching aligned with factor requirements and verification states returned by Clerk.
- API usage patterns
- Use Clerk sign-in/sign-up APIs and verification methods with structured success/failure handling.
- Keep request/response handling explicit and status-driven.
- Use Clerk error helpers/messages for user-visible errors.
- OAuth/social policy
- Use provider flows supported by Clerk APIs.
- For Google, honor runtime One Tap capability and use the appropriate Clerk path.
- Do not bypass Clerk by implementing provider-specific token exchange directly unless explicitly requested.
- Code organization and separation of concerns
- Split custom auth into focused modules:
- UI step views/components
- Flow/state orchestration (view models/state machines)
- Clerk API integration layer
- Keep module boundaries clear and composable.
- Avoid hidden dependencies
- Do not silently add prebuilt UI dependencies to custom-only implementations.
- Do not introduce local config indirection for publishable key unless requested.
Verification Checklist
- Quickstart prerequisites are complete
- Required Android/Clerk setup from quickstart is present.
- Missing required setup was applied.
- Correct artifact usage
clerk-android-apiis present.clerk-android-uiis absent unless explicitly required.
- Initialization and auth state handling
- UI/runtime waits for
Clerk.isInitialized. - Auth/session/user state derives from Clerk flows.
- Capability-driven behavior
- Flow branches align with runtime capabilities and dashboard configuration.
- No hardcoded factor/provider matrix independent of Clerk state.
- Multi-step auth quality
- Flow uses explicit steps with clear transitions.
- Required fields and verifications are fully covered.
- Architecture quality
- UI, orchestration, and Clerk integration are separated into focused files/modules.
- OAuth/social correctness
- OAuth handling uses Clerk APIs and supported provider paths.