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

# Install the Subtext Snippet in Your React Application

> Add the Subtext capture snippet to your React application by inserting the script tag into your root HTML template, public/index.html.

For standard React applications — whether bootstrapped with Create React App or any other toolchain that serves a static `public/index.html` — the simplest installation path is to paste the Subtext capture snippet directly into the `<head>` of that file. The snippet loads asynchronously and begins recording sessions as soon as the page is visited, with no impact on your bundle size.

<Note>
  You can also run `npx @subtextdev/subtext-wizard` in your project root to have Subtext detect your framework and insert the snippet automatically. Follow this guide if you prefer to wire things up by hand.
</Note>

<Steps>
  <Step title="Find your Org ID">
    Log in to Subtext and open **Settings**. Your Org ID is listed in the **Capture** section. Copy it — you will paste it in place of `YOUR_ORG_ID` in the snippet below.
  </Step>

  <Step title="Open public/index.html">
    Open `public/index.html` in your editor. This is the HTML shell that React mounts into — it is served for every route in your application. If you are using a custom HTML template, open that file instead.
  </Step>

  <Step title="Paste the snippet into the head">
    Add the snippet inside the `<head>` tag, just before the closing `</head>`. Replace `YOUR_ORG_ID` with the Org ID you copied from Subtext settings.

    ```html public/index.html theme={null}
    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <title>My App</title>

        <!-- Subtext capture snippet -->
        <script>
          window['_fs_host'] = 'fullstory.com';
          window['_fs_script'] = 'edge.fullstory.com/s/fs.js';
          window['_fs_org'] = 'YOUR_ORG_ID';
          window['_fs_namespace'] = 'FS';
          !function(m,n,e,t,l,o,g,y){var s,f,a=function(h){return!(h in m)||(m.console&&m.console.log&&m.console.log('FullStory namespace conflict. More info: https://www.fullstory.com/developer/ns.html'),!1)};if(a(l)&&a(n)){m[l]={q:[]};var d=function(){return Array.prototype.slice.call(arguments,0)};m[l].identify=function(){m[l].q.push(["identify"].concat(d.apply(null,arguments)))};m[l].setUserVars=function(){m[l].q.push(["setUserVars"].concat(d.apply(null,arguments)))};m[l].event=function(){m[l].q.push(["event"].concat(d.apply(null,arguments)))};m[l].anonymize=function(){m[l].q.push(["anonymize"].concat(d.apply(null,arguments)))};m[l].shutdown=function(){m[l].q.push(["shutdown"].concat(d.apply(null,arguments)))};m[l].restart=function(){m[l].q.push(["restart"].concat(d.apply(null,arguments)))};m[l].log=function(a,b){m[l].q.push(["log",a,b])};m[l].consent=function(){m[l].q.push(["consent"].concat(d.apply(null,arguments)))};m[l].identifyAccount=function(){m[l].q.push(["identifyAccount"].concat(d.apply(null,arguments)))};m[l].clearUserCookie=function(){m[l].q.push(["clearUserCookie"].concat(d.apply(null,arguments)))};m[l].setVars=function(){m[l].q.push(["setVars"].concat(d.apply(null,arguments)))};m[l]._w={};y="XMLHttpRequest";m[l]._w[y]=m[y];y="fetch";m[l]._w[y]=m[y];if(m[y])m[l]._w[y]=m[y];m[l]._v="1.3.0";g=n.createElement(e);g.async=1;g.crossOrigin="anonymous";g.src='https://'+m[_fs_script];y=n.getElementsByTagName(e)[0];y.parentNode.insertBefore(g,y)}}(window,document,"script","_fs_config",n,o,g,y);
        </script>

      </head>
      <body>
        <div id="root"></div>
      </body>
    </html>
    ```
  </Step>

  <Step title="Start or rebuild your app">
    Run `npm start` (Create React App) or `npm run dev` (Vite-based setups) and open your application in a browser. For production, rebuild with `npm run build` and deploy normally — the snippet is embedded in the static HTML shell.
  </Step>

  <Step title="Verify capture is working">
    Navigate to a few pages in your app, then open **Subtext → Sessions**. A new session should appear within a minute or two.

    <Tip>
      Sessions typically appear within 30–60 seconds of page load. If nothing shows up, confirm that `YOUR_ORG_ID` was replaced with your actual Org ID and that `public/index.html` is the HTML file being served by your development server.
    </Tip>
  </Step>
</Steps>

<Note>
  The snippet records full production sessions and masks all form inputs by default. Your agent can flag additional PII and propose masking rules for your review from within Subtext.
</Note>
