> ## Documentation Index
> Fetch the complete documentation index at: https://docs.schemagen.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Install the SchemaGen SDK on Your Website in Minutes

> Add the SchemaGen SDK snippet once to HTML, WordPress, Shopify, or Next.js sites to enable real-time JSON-LD delivery from your dashboard.

The SchemaGen SDK is a lightweight JavaScript snippet that connects your website to the Schema Delivery Network. When a visitor loads a page, the SDK reads the current URL, fetches any published schemas that match that page from SchemaGen's edge network, and injects them into the DOM as `<script type="application/ld+json">` tags — automatically, with no further action required from you.

You install the SDK once. Every schema you publish, update, or pause from the dashboard takes effect immediately across all matching pages on your site.

<Note>
  The SDK is lightweight and edge-optimized. It loads asynchronously so it never blocks page rendering, and schema delivery is served from edge locations worldwide to minimize latency.
</Note>

## Find your Client ID

Before you install the SDK, locate your **Client ID**. This unique identifier tells the SDK which schemas to fetch for your site.

To find it: in the SchemaGen dashboard, go to **Settings → Client**. Your Client ID is displayed there. Copy it — you'll paste it into the SDK snippet below.

## Install the SDK

Choose the installation method that matches your site setup.

<Tabs>
  <Tab title="HTML / Static">
    Add the following snippet inside the `<head>` tag of every page on your site. If you use a shared layout or template file, add it there so it appears on all pages automatically.

    Replace `YOUR_CLIENT_ID` with the Client ID from your dashboard.

    ```html HTML theme={null}
    <script async
      src="https://schemagen.io/sdk.js"
      data-client-id="YOUR_CLIENT_ID">
    </script>
    ```

    Place the tag as early in the `<head>` as possible to give the SDK time to fetch schemas before the page finishes rendering.
  </Tab>

  <Tab title="WordPress">
    The best way to add the SDK to WordPress is via your theme's `functions.php` file or a site-wide plugin like **Code Snippets**.

    Add the following to your `functions.php` file (or a custom plugin):

    ```php functions.php theme={null}
    function schemagen_sdk() {
      echo '<script async src="https://schemagen.io/sdk.js" data-client-id="YOUR_CLIENT_ID"></script>';
    }
    add_action( 'wp_head', 'schemagen_sdk' );
    ```

    Replace `YOUR_CLIENT_ID` with the Client ID from your dashboard.

    <Tip>
      If you're using a page builder like Elementor or a theme with a **Custom Code** or **Header Scripts** field, you can paste the raw `<script>` tag there instead of editing `functions.php`.
    </Tip>

    After saving, load any page on your site and verify the script tag appears in the page source.
  </Tab>

  <Tab title="Shopify">
    In your Shopify admin, go to **Online Store → Themes → Edit code**. Open `layout/theme.liquid` and paste the snippet just before the closing `</head>` tag.

    Replace `YOUR_CLIENT_ID` with the Client ID from your dashboard.

    ```html theme.liquid theme={null}
    <script async
      src="https://schemagen.io/sdk.js"
      data-client-id="YOUR_CLIENT_ID">
    </script>

    </head>
    ```

    Click **Save**. The SDK will now load on every page of your storefront.

    <Note>
      Shopify's online storefront renders different URLs for product pages, collections, blogs, and the homepage. SchemaGen matches schemas by the exact URL the SDK detects, so make sure your target URLs in the dashboard match your Shopify URL structure (for example, `https://your-store.myshopify.com/products/example-product`).
    </Note>
  </Tab>

  <Tab title="Next.js / React">
    In Next.js, use the built-in `next/script` component to load the SDK. Add it to your root layout so it appears on every page.

    Replace `YOUR_CLIENT_ID` with the Client ID from your dashboard.

    ```jsx app/layout.jsx theme={null}
    import Script from 'next/script'

    export default function RootLayout({ children }) {
      return (
        <html>
          <body>
            {children}
            <Script
              src="https://schemagen.io/sdk.js"
              data-client-id="YOUR_CLIENT_ID"
              strategy="afterInteractive"
            />
          </body>
        </html>
      )
    }
    ```

    The `afterInteractive` strategy loads the SDK after the page becomes interactive, keeping it out of the critical rendering path while ensuring schemas are injected before users interact with the content.

    <Tip>
      If you're using the Pages Router instead of the App Router, add the `<Script>` component to `pages/_app.jsx` in the same way.
    </Tip>
  </Tab>
</Tabs>

## How the SDK works

When the SDK loads on a page, it:

1. Reads the current page URL from the browser.
2. Sends a request to the SchemaGen inject API: `GET /api/inject?clientId={clientId}&url={pageUrl}`.
3. Receives a list of published schemas matching that URL.
4. Injects each schema as a `<script type="application/ld+json">` tag into the page DOM.

Schemas are only delivered if they match the target URL you configured in the dashboard and have a **Published** status. Drafts and paused schemas are never delivered to the browser.

## Verify the SDK is working

After installing the SDK, confirm it's injecting schemas correctly.

<Steps>
  <Step title="Open DevTools">
    Navigate to a page where you have a published schema. Open your browser's developer tools (press `F12` or right-click → **Inspect**).
  </Step>

  <Step title="Check the Elements panel">
    In the **Elements** tab, search for `application/ld+json` (use `Ctrl+F` or `Cmd+F` to search within the DOM). You should see one or more `<script type="application/ld+json">` tags containing your schema JSON.
  </Step>

  <Step title="Check the Network panel">
    In the **Network** tab, filter by `Fetch/XHR` and reload the page. Look for a request to `schemagen.io/api/inject` — this confirms the SDK is running and communicating with the SchemaGen edge network.
  </Step>
</Steps>

<Warning>
  If you don't see schemas being injected, double-check that the `data-client-id` attribute contains your correct Client ID, that the target URL in your dashboard exactly matches the page URL (including protocol and path), and that the schema has a **Published** status — not Draft or Paused.
</Warning>

## Next steps

<CardGroup cols={2}>
  <Card title="Quick start guide" icon="rocket" href="/quickstart">
    Walk through creating and publishing your first schema end to end.
  </Card>

  <Card title="SDN overview" icon="network-wired" href="/sdn/overview">
    Learn how the Schema Delivery Network routes and caches schema delivery.
  </Card>

  <Card title="Publishing and lifecycle" icon="toggle-on" href="/sdn/publishing">
    Understand how Draft, Published, and Paused states affect schema delivery.
  </Card>

  <Card title="Domain locking" icon="lock" href="/sdn/domain-locking">
    Restrict your Client ID to specific domains to prevent unauthorized use.
  </Card>
</CardGroup>
