schematic-vue
schematic-vue is a client-side Vue library for Schematic which provides composables to track events, check flags, and more. schematic-vue provides the same capabilities as schematic-js, for Vue apps.
Install
Usage
SchematicPlugin
You can use the SchematicPlugin to make Schematic available throughout your Vue application:
Setting context
To set the user context for events and flag checks, you can use the identify function provided by the useSchematicEvents composable:
To learn more about identifying companies with the keys map, see key management in Schematic public docs.
Tracking usage
Once you’ve set the context with identify, you can track events:
If you want to record large numbers of the same event at once, or perhaps measure usage in terms of a unit like tokens or memory, you can optionally specify a quantity for your event:
Checking flags
To check a flag, you can use the useSchematicFlag composable:
Checking entitlements
You can check entitlements (i.e., company access to a feature) using a flag check as well, and using the useSchematicEntitlement composable you can get additional data to render various feature states:
Note: useSchematicIsPending is checking if entitlement data has been loaded, typically via identify. It should, therefore, be used to wrap flag and entitlement checks, but never the initial call to identify.
Options API Support
While the primary API uses the Composition API, you can still use these composables in the Options API:
Troubleshooting
For debugging and development, Schematic supports two special modes:
Debug Mode
Enables console logging of all Schematic operations:
Offline Mode
Prevents network requests and returns fallback values for all flag checks:
Offline mode automatically enables debug mode to help with troubleshooting.
Advanced Usage
Using a Pre-configured Client
If you need more control over the Schematic client initialization, you can create a client instance and pass it to the plugin:
Per-Component Client Override
You can override the client for a specific component by passing a client option to any composable:
Server-Side Rendering (SSR)
All composables are SSR-compatible and work seamlessly with Nuxt and other Vue SSR frameworks:
- Initial flag/entitlement values are retrieved synchronously for server-side rendering
- Real-time subscriptions are deferred to client-side hydration
- No special configuration needed - it just works!
License
MIT
Support
Need help? Please open a GitHub issue or reach out to support@schematichq.com and we’ll be happy to assist.