For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
SupportDashboard
Getting StartedAPI ReferenceRoadmapBlog
Getting StartedAPI ReferenceRoadmapBlog
  • Getting Started
    • Overview
    • What is Schematic?
    • Concepts
  • Using Schematic
    • Who Uses Schematic
  • Quickstart
    • Quickstart
    • Account Setup
    • Entitling a Feature
    • Tracking Usage
    • Components
    • Identifying Users
    • Setup the SDK
  • Using Feature Flags
    • Overview
    • Flags
    • Features
    • Tracking Feature Usage
    • Company Overrides
    • Feature Types
  • Building Your Catalog
    • Overview
    • Plans
    • Managing Company Plans
    • Configuring the Catalog
    • Add Ons
    • Trials
  • AI Tooling
    • For Developers
  • Setting Up Billing
    • Overview
    • Usage Based Billing Models
    • Seat Based Billing Models
    • Credit burndown
  • Using UI Components
    • Overview
  • Developer Resources
    • Concepts
    • Key Management
    • Environments
    • Entity Relationship Diagram
  • Production Readiness
    • Availability
    • Observability & Support
    • Security
  • Integrations
    • Segment Integration
    • Clerk Integration
    • WorkOS Integration
    • Salesforce Integration
    • Hubspot Integration
  • Playbooks
    • Overview
    • Creating a metered feature
    • Backfills and usage corrections
    • Rolling out beta functionality with Flags
    • Handling customer exceptions and feature trials
    • Automatically provision customers using Stripe
    • Build a slack webhook
LogoLogo
SupportDashboard
On this page
  • Install
  • Usage
  • SchematicProvider
  • Identifying the user with Schematic
  • Check a flag
  • Next Steps!
Quickstart

Setup the SDK

Integrate the Schematic SDK into your application
Was this page helpful?
Previous

Feature Management Overview

Next
Built with

The schematic-react SDK is a client-side React library for Schematic which provides hooks to track events, check flags, and more.

Install

$npm install @schematichq/schematic-react
$# or
$yarn add @schematichq/schematic-react
$# or
$pnpm add @schematichq/schematic-react

Usage

SchematicProvider

Similar to libraries like Clerk, Use the SchematicProvider to wrap your application and provide the Schematic instance to all components:

1`use client`
2
3import { SchematicProvider } from "@schematichq/schematic-react";
4
5ReactDOM.render(
6 <SchematicProvider publishableKey="your-publishable-key">
7 <App />
8 </SchematicProvider>,
9 document.getElementById("root"),
10);
At this time, the React SDK only supports client-side rendering.

You can generate a publishable key from the Schematic Dashboard. These keys look like api_... and are meant to be used client-side.

Generating API keys in Schematic

Identifying the user with Schematic

To set the user context for events and flag checks, you can use the identify function provided by the useSchematicEvents hook. The example below assumes your company has an application id of company123. This will upsert the company into Schematic, and set the context for the current web session (i.e. later calls will operate on this company).

1import { useSchematicEvents } from "@schematichq/schematic-react";
2
3const MyComponent = () => {
4 const { identify } = useSchematicEvents();
5
6 useEffect(() => {
7 identify({
8 company: {
9 keys: { id: "company123" },
10 },
11 });
12 }, []);
13
14 return <div>My Component</div>;
15};
See Key Management for more information on keys and how to use them in Schematic.

Check a flag

To check our flag, you can use the useSchematicFlag hook:

1import { useSchematicFlag } from "@schematichq/schematic-react";
2import { Feature, Fallback } from "./components";
3
4const MyComponent = () => {
5 const isFeatureEnabled = useSchematicFlag("mechanical-keyboard");
6
7 return isFeatureEnabled ? "Cherry MX Blues" : "1990's Logitech Keyboard";
8};

Next Steps!

Congrats 🎉! Now you have the basics setup to start using Schematic.

If you’d like to dig deeper into our SDK and platform, here are a few places to start:

  • Out of the box components
  • Usage-based plans
  • Backend SDKs
  • Integrations
  • Events

If you’d like to learn more about how Schematic can build and manage your pricing and billing, here are a few places to start:

  • Building your pricing catalog
  • Usage-based plans
  • Per-company overrides
  • Legacy plan management
  • Trials
  • Add Pns