A React waitlist component for Vite and Create React App

A React app is a set of components that mount and unmount as people move around. A LaunchSuite waitlist fits that model with one TypeScript component that renders the embed container, loads the script once, and falls back to an iframe where the script can't do its job.

This guide shows the component for Vite and Create React App, explains why the script only mounts the form on a page load, and covers the cases where you should use the iframe instead: modals, tabs and routes reached by in-app navigation.

What gets in the way

Client-side routes don't reload the page
Single-page apps swap views without a page load. embed.js scans the document once, when it runs. A component that mounts later, after a route change or a data fetch, can render an empty div because the script has already finished its scan.
Dialogs and tabs mount content late
A signup form inside a modal, a drawer or an inactive tab is not in the DOM until someone opens it. The same empty-div problem applies, so those spots need the iframe, which needs no scan.
StrictMode loads the script twice
React's StrictMode runs effects twice in development. A component that appends the script on every run would load embed.js twice, and the second copy registers its own message listener. The component checks for an existing script tag before it adds one.
React and the script both touch the same div
The embed adds an iframe inside the container. Keep the container empty in your JSX. If it has React children, later renders can fail when React looks for nodes that the script has moved around it.

Add a waitlist component to a React app

These steps work in a Vite project or a Create React App project with TypeScript. Replace your-slug with the slug from your project's Embed tab, and publish the project before you test, since an unpublished waitlist shows a not-found page.

  1. 01

    Publish the project and copy the slug

    Open your project in LaunchSuite, publish the waitlist page, and open the Embed tab. Copy the slug. The component takes it as a prop, so one component can serve several waitlists.

  2. 02

    Create the script-based component

    Save this as src/components/WaitlistForm.tsx. It renders the container, then appends embed.js in an effect only when the script is missing from the document.

    import { useEffect } from "react";
    
    const EMBED_SRC = "https://launchsuite.co/embed.js";
    
    type WaitlistFormProps = {
      slug: string;
      transparent?: boolean;
    };
    
    export function WaitlistForm({ slug, transparent = false }: WaitlistFormProps) {
      useEffect(() => {
        if (document.querySelector(`script[src="${EMBED_SRC}"]`)) return;
        const script = document.createElement("script");
        script.src = EMBED_SRC;
        script.async = true;
        document.body.appendChild(script);
      }, []);
    
      return (
        <div
          data-launchsuite-waitlist={slug}
          data-transparent={transparent ? "true" : undefined}
        />
      );
    }
  3. 03

    Render it on a page that loads directly

    Import the component into a page that a visitor can open with a full page load, such as the landing page. The container has no children, so React has nothing to fight the embed over.

    import { WaitlistForm } from "./components/WaitlistForm";
    
    export function Landing() {
      return (
        <section>
          <h1>Join the waitlist</h1>
          <WaitlistForm slug="your-slug" />
        </section>
      );
    }
  4. 04

    Add the iframe component for dialogs and in-app routes

    Create this second component for anything that mounts after the page loads. It needs no script, so it works inside a modal, a tab or a route you reach with a router link.

    type WaitlistIframeProps = {
      slug: string;
      height?: number;
    };
    
    export function WaitlistIframe({ slug, height = 220 }: WaitlistIframeProps) {
      return (
        <iframe
          src={`https://launchsuite.co/embed/${encodeURIComponent(slug)}`}
          title="Join the waitlist"
          loading="lazy"
          style={{ width: "100%", height, border: 0 }}
        />
      );
    }
  5. 05

    Test a production build

    Run your build command, then serve the output. With Vite that is pnpm build followed by pnpm preview. Open the landing page directly, check the script form, then navigate in the app and check the iframe. Submit one test signup and confirm the contact appears in Contacts.

The slug is public, so it can sit in the bundle. Use import.meta.env in Vite or process.env with the REACT_APP_ prefix in Create React App when staging and production need different waitlists.

StrictMode mounts effects twice in development. The existence check in WaitlistForm keeps one script tag in the document.

Use WaitlistIframe for modals, drawers, tabs and any route reached by in-app navigation.

The Free plan shows a Built with LaunchSuite line under the form. Removing it is part of Pro.

Choose the script or the iframe in a SPA

The script works well when the form is on the first page a visitor loads, such as a landing page at the root of a Vite app. It resizes the frame to fit, passes the page URL so visits show their source, and supports data-transparent for dark backgrounds.

The iframe is the dependable choice for everything else. It needs no global script state, it mounts whenever the component mounts, and it works with any router. You set the height, so the form must fit that height with the default fields. Use the iframe for any form inside a dialog or any route that visitors reach without a full page load.

How the component loads the script once

The component renders the container first, then adds the script in useEffect. Effects run after React commits the DOM, so the div already exists when embed.js starts its scan. The script is appended only when no script tag with that source is in the document, which keeps StrictMode and repeated mounts from loading it twice.

The check does not solve the scan problem. If the script already ran earlier in the session, a new container created later stays empty. That is the reason the iframe component exists alongside this one, and why the example below uses the iframe.

Typing the props

Keep the props minimal: the slug from the Embed tab and an optional transparent flag. Both are public values, since the embed URL is visible to anyone who views the page source, so the slug can live in your code or in an environment variable. Vite exposes environment variables through import.meta.env, and Create React App through process.env with the REACT_APP_ prefix. Use one per environment if your staging page and production page use different waitlists.

data-* attributes are accepted on plain JSX elements, so the container needs no type assertion. The data-transparent value is a string, which is why the component maps the boolean to "true" or leaves the attribute undefined.

Example: a Vite landing page with a waitlist dialog

Say you're building a hypothetical budgeting app for couples with Vite and React. The landing page is the main route, and a Get early access button opens a dialog with the waitlist form inside. The app itself is not ready, and the signup form has to work the first time someone opens the dialog and every time after.

  1. 01

    Publish the waitlist and note the slug

    Build the page in the builder, publish it, and copy the slug from the Embed tab. In this example it is couples-budget. The slug goes into a constant, since it is public.

  2. 02

    Use the iframe inside the dialog

    A dialog mounts its content when it opens, so the script's one-time scan would miss the form. The app renders the iframe component inside the dialog body with a height of 240px, which fits the email field and the button.

  3. 03

    Keep the landing page on the script

    The main landing page loads directly, so the WaitlistForm component with the script works there. The dialog and the landing form are separate, and each one uses the method that fits its mount timing.

  4. 04

    Test open, close and reopen

    Open the dialog, close it, and open it again. The iframe mounts each time, so the form appears on every open. Submit a test signup on the second open to confirm that a remounted frame still records the signup.

  5. 05

    Test a direct load in a production build

    Run the production build and serve it. Load the landing page directly, check that the script form appears, then click into the dialog. Both routes should show a working form without a console error.

The landing page collects emails through the script, the dialog collects them through the iframe, and every signup lands in one contact list with a confirmation email. When the app launches, the list can receive a launch-day email from a flow with the manual trigger, which is a Pro feature.

Start from a template

The SaaS beta template suits an app that isn't live yet, with a headline, a short description and one email field. The dialog pattern in this guide works with that layout, so change the copy and keep the form above the fold.

Open the template or compare Free and Pro

Free covers one project for good. Pro starts at $4.92 a month, billed yearly.

Questions people ask

Why not add the script tag to index.html?

It works for a form on the first page load, but it's fragile. The script scans the document once. If it runs before React renders the container, the form never appears, and if it runs after a later route change, the same problem happens. Keeping the script in the component puts the form and its load in one place.

Does the component need a provider or context?

No. It has no state and reads nothing from context, so it works anywhere in the tree. You can render it inside a layout, a page or a feature component without wrapping it in anything.

How does the height work with the script?

The script starts the frame at 160px and resizes it to the form's content height once the form has loaded. The iframe component does not resize, so set the height prop to fit your layout.

Can I read the signups inside my React app?

Not through the embed. Signups go to LaunchSuite's Contacts list and analytics. If you use an AI client with the LaunchSuite MCP server, it can list signups, and CSV export is available on Pro for a copy of the list.

Is the slug a secret?

No. The slug is part of the public embed URL, and anyone who views the page source can see it. Its only job is to say which waitlist to show, so there is nothing to protect in it.

Does this work with React Router or TanStack Router?

Both routers work. Use the script component on a route visitors reach with a full page load, and the iframe component on any route reached by in-app navigation. The router doesn't change either choice.

Keep reading