M0rphicProvider
The context provider that initializes the SDK and makes it available throughout your app.
Basic Usage
typescript
Props
| Prop | Type | Default | Description |
|---|---|---|---|
appId* | string | - | Your m0rphic application ID from the dashboard. |
apiEndpoint | string | "https://api.m0rphic.dev" | API endpoint URL. Override for self-hosted or staging environments. |
userId | string | - | Explicit user ID. If not provided, tracking requires manual setUserId call. |
privacy | PrivacyConfig | - | Privacy settings for data collection. |
children* | React.ReactNode | - | Your application components. |
Privacy Configuration
Configure privacy settings to control how user data is collected and processed:
typescript
PrivacyConfig Options
| Prop | Type | Default | Description |
|---|---|---|---|
hashUserId | boolean | false | Hash user IDs with SHA-256 before sending to the server. |
respectDNT | boolean | false | Respect the browser's Do Not Track setting. |
Accessing the Context
Use the useM0rphic hook to access the SDK context:
typescript
Tip
Use isTracking to check if event tracking is active. It will be false if user opted out or DNT is enabled.
Environment Variables
Store your App ID in environment variables for different environments:
.env
typescript