Example Projects
Learn how to use the m0rphic SDK through complete example projects. These projects demonstrate best practices for all core features.
React Example App
A complete React application showcasing all features of the @m0rphic/react SDK. Includes event tracking, component rendering, and a real-time debug panel.
Features
- •
M0rphicProvider- Session tracking (session_start/session_end) - •
M0rphicComponent- AI component rendering with automatic click and view tracking - •
useTrackComponent- Manual component tracking with hover support - •
useTrackScroll- Scroll depth tracking (25%, 50%, 75%, 100%) - •
M0rphicErrorBoundary- Error boundary with automatic error event reporting
Quick Start
bash
Test Mode Note
The example app uses e2e-test-example-app as the default appId, which requires E2E_TEST_MODE=true on the server to bypass authentication.
Event Tracking Overview
The SDK supports the following event types for collecting user behavior data:
| Event Type | Trigger | Automatic |
|---|---|---|
session_start | Provider mounts | Yes |
session_end | Page closes or tab switches | Yes |
view | Element visible (>50%) | Yes |
click | User clicks | Yes |
submit | Handler is invoked | Yes |
hover | Hover exceeds threshold | Opt-in |
scroll | Scroll reaches milestone | Opt-in |
error | Error boundary catches error | Opt-in |
Source Code
View the complete source code:
- •m0rphic-dev/example - React example app full source
- •m0rphic-dev/react-sdk - React SDK source code