Overview
Follow these best practices to build secure, production-ready applications with CDP wallets. This guide covers security recommendations, state management patterns, user experience tips, and a production readiness checklist.Security recommendations
- Domain allowlisting: Always configure your allowed domains in CDP Portal
- HTTPS only: Never use CDP wallets on non-HTTPS sites in production
- Rate limiting: Implement rate limiting on your authentication endpoints
- Session management: Use appropriate session timeouts for your use case
State management
-
Always check authentication state: Before starting any authentication flow, verify if the user is already signed in:
-
Implement sign out: Provide a clear way for users to sign out:
For React applications, use the
AuthButtoncomponent which handles sign out automatically, or theuseSignOuthook: -
Avoid redundant verification: Don’t call
verifyEmailOTPorverifySmsOTPwhen a user is already authenticated. This will result in an error and may leave your application in an inconsistent state.
User experience tips
- Clear messaging: Explain why users need to verify their email
- Error handling: Provide helpful error messages for common issues
- Loading states: Show progress during authentication steps
- Success feedback: Confirm when authentication is complete
Choosing the right approach
When to use React hooks
When to use React hooks
Use
@coinbase/cdp-hooks when:- You need custom authentication UI
- You want to control the authentication flow step-by-step
- You need to integrate with existing form components
- You want fine-grained control over error handling
- You’re building a custom authentication experience
When to use direct methods
When to use direct methods
Use
@coinbase/cdp-core when:- Building vanilla JavaScript/TypeScript applications
- Working with frameworks other than React (Vue, Angular, Svelte, etc.)
- You need maximum control over the authentication flow
- Building server-side applications
- Creating custom authentication wrappers for any framework
What to read next
- Authentication Methods: Learn about available authentication options
- Implementation Guide: Step-by-step authentication integration
- Session Management: Understand session lifecycle and token management
- Server-side validation: Validate user sessions on your backend
- Security Configuration: Configure domain allowlisting and security settings
- React Components: Ready-to-use UI components including AuthButton