Morph
Morph.Provider
The Morph.Provider
component initializes the Morph SDK and provides configuration context throughout your application.
The Morph.Provider
component is a crucial setup component that must wrap your application to enable Morph functionality. It:
- Initializes the Morph SDK with your configuration
- Provides configuration context to all Morph components
- Automatically handles environment variable detection
- Manages the Morph client instance lifecycle
Installation
Environment Variables
The provider automatically detects your public key from the following environment variables (in order of precedence):
MORPH_PUBLIC_KEY
NEXT_PUBLIC_MORPH_PUBLIC_KEY
VITE_MORPH_PUBLIC_KEY
REACT_APP_MORPH_PUBLIC_KEY
Usage
Props
The child components that will have access to the Morph context.
Best Practices
- Place the
MorphProvider
as high as possible in your component tree - Use environment variables for public key management in development
- Explicitly pass configuration in production environments
- Implement error boundaries around the provider for graceful error handling
Security Considerations
- Never expose your private key through the provider
- Use appropriate environment variable prefixes for your framework
- Implement proper CSP policies for your deployment environment
- Keep your public key secure and rotate if compromised