M0rphicProvider

The context provider that initializes the SDK and makes it available throughout your app.

Basic Usage

typescript

Props

PropTypeDefaultDescription
appId*string-Your m0rphic application ID from the dashboard.
apiEndpointstring"https://api.m0rphic.dev"API endpoint URL. Override for self-hosted or staging environments.
userIdstring-Explicit user ID. If not provided, tracking requires manual setUserId call.
privacyPrivacyConfig-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

PropTypeDefaultDescription
hashUserIdbooleanfalseHash user IDs with SHA-256 before sending to the server.
respectDNTbooleanfalseRespect 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