Skip to main content

Vite and Create React App

Client-rendered React apps have one HTML file. Add the tag to its <head>, before your app’s script:
index.html
With Create React App, the file is public/index.html.
  • No hydration wait. A client-rendered app has no server HTML to hydrate, so leave out data-await-hydration.
  • Content your app renders later: pagent applies a variant when the page loads and on every route change. If a test targets content that appears only after data has loaded, open the test’s preview link and check that the variant shows.
  • Routing: React Router’s browser router is tracked automatically. With HashRouter, send a navigate command on every route change, as described in Frameworks.

Remix and React Router (framework mode)

Server-rendered apps render the document in app/root.tsx. Add the tag at the top of its <head>, with data-await-hydration="true":
app/root.tsx
pagent recognizes Remix and React Router hydration, and tracks client-side navigation automatically. See Frameworks for the shared rules and the Content Security Policy.

Check it worked

  1. Deploy, then open your site in a private browser window.
  2. Back in pagent, click Check connection in the install step.
  3. Open a test’s preview link and check that the variant shows and stays after the page has finished loading.