Seatext library

Required Server-Side Rendering Configurations for SeaText AI

SeaText AI runs as a lightweight client-side script that must execute after the page is hydrated and have access to the rendered DOM. Place the snippet at the end of <body>, ensure no Content...

What SeaText AI needs from your rendering stack

SeaText AI is delivered as a single JavaScript snippet that rewrites page text in the browser. It does not require a special server runtime, but it does require that the final HTML reaches the browser with a fully constructed DOM so the script can locate and modify text nodes. In practice this means:

  • The snippet must be present in the HTML that the server sends (or injected by your framework before hydration completes).
  • The script must run after the framework has finished hydrating the page, otherwise the DOM nodes SeaText targets may not exist yet.
  • No CSP directive may block the script origin or inline execution.
  • The browser must allow localStorage access for the visitor ID SeaText stores.

If your stack uses server-side rendering (Next.js, Nuxt, Astro, Remix, etc.), treat the snippet like any other third-party analytics or chat widget: include it in the shared layout or <body> so it ships with every server-rendered page.

Placement checklist

  1. Add the snippet once in your root layout. In Next.js App Router this is app/layout.tsx; in Nuxt 3 it is app.vue or a plugin; in Astro it is a layout component. Paste the SeaText snippet just before the closing </body> tag.
  2. Keep the async attribute. The snippet ships with async so it never blocks parsing or paint. Do not remove it.
  3. Verify CSP allows the script origin. Add script-src 'https://cdn.seatext.com' (or the exact domain your snippet references) to your Content-Security-Policy header or meta tag.
  4. Confirm localStorage is not blocked. Some privacy extensions or sandboxed iframes disable storage. SeaText falls back gracefully, but the visitor ID persists best when storage works.
  5. Test cross-origin scenarios. If your SSR app serves multiple subdomains or uses a separate CDN domain for assets, ensure the snippet loads from the same origin or that CORS headers allow it.
  6. Run a hydration check. After deployment, open DevTools → Console and confirm the SeaText script loads without errors. Then verify that text variants appear on the page.

Why hydration timing matters

SeaText rewrites headlines, buttons, and proof points by walking the live DOM. If the script runs before React, Vue, or Svelte finishes hydrating, the target elements may still be placeholders or missing entirely. The result is either no rewrites or a flash of original content. Placing the snippet at the end of <body> in your server-rendered template guarantees it executes after the framework's hydration script because browsers run scripts in document order.

When hydration finishes, the DOM contains the final markup that SeaText can scan. The script then replaces text nodes in‑place, preserving the existing layout and avoiding any shift. This timing also ensures that any client‑side state set by the framework (such as user‑specific props) is already applied before SeaText makes its changes.

Performance characteristics that affect SSR decisions

  • Script size: under 15 KB gzipped. This keeps the network transfer small and helps maintain a good Time to First Byte.
  • Execution time: under 15 ms before first paint. The script runs quickly enough to stay within the browser’s idle budget and not delay the first meaningful paint.
  • Cumulative Layout Shift: zero — the script swaps text in‑place without inserting new layout boxes, so it does not contribute to CLS.
  • Network: single request to SeaText CDN, cached aggressively by browsers and CDNs, reducing repeat fetches.

These numbers mean you can safely include the snippet on every SSR page without hurting Core Web Vitals. There is no need to lazy‑load or defer it further.

Framework-specific notes

Next.js (App Router)

Add the snippet in app/layout.tsx inside the <body> tag. Because Next.js streams the shell first, the snippet arrives in the initial HTML and runs after React hydrates the interactive islands. The async attribute ensures it does not block the streaming of subsequent chunks.

Nuxt 3

Use a client-only plugin (plugins/seatext.client.ts) that injects the snippet into document.body on mounted, or paste it directly in app.vue inside <body>. The plugin approach keeps the snippet out of the server bundle while still guaranteeing it runs after Nuxt’s hydration process.

Astro

Astro renders static HTML by default. Include the snippet in a base layout (layouts/Base.astro) before </body>. If you enable client:load islands, the snippet still runs after the island hydrates because it sits after the island scripts in the HTML order.

Remix / React Router v7

Place the snippet in app/root.tsx inside the <body> of the Layout component. Remix streams the document, so the snippet loads with the initial chunk and executes after Remix’s hydration finishes.

Common mistakes

MistakeSymptomFix
Snippet placed in <head>Script runs before <body> exists; rewrites failMove to end of <body>
CSP blocks script originConsole error "Refused to load script"Add SeaText CDN to script-src
Snippet bundled by frameworkDouble execution or missing asyncKeep snippet as raw HTML, not imported JS
SSR disabled for the pageSeaText works but you lose SSR benefitsEnable SSR; SeaText does not require CSR
LocalStorage blockedVisitor ID resets every page viewAllow storage or accept session-only tracking
Using defer instead of asyncScript may delay until after DOMContentLoaded, causing a flash of original contentKeep the async attribute as provided

Key facts

PropertyValueSource
Script loadingAsynchronous (async attribute)S1
Script weightUnder 15 KBS3
Execution latencyUnder 15 ms before visual paintS3
Cumulative Layout ShiftZeroS3
Storage requirementlocalStorage for visitor IDS1
Cross‑origin noteVerify compatibility across domainsS1
PlacementEnd of <body> in entry HTMLS1

Limitations

  • SeaText does not run on the server; it cannot rewrite HTML before it leaves your origin. All rewrites happen client‑side after hydration.
  • If your SSR setup strips scripts from the initial HTML (e.g., aggressive sanitization), the snippet will not load.
  • Pages served from a CDN edge that does not forward the snippet will not get rewrites.
  • The checklist above covers the SeaText script only. Your framework may have its own SSR requirements (Node version, streaming support, etc.) that are outside SeaText's scope.

Benefits and typical use cases

SeaText AI can rewrite headlines, buttons, offers and product copy to match the visitor’s source, such as a Google Ads keyword or a Meta campaign. This real‑time matching has been reported to lift conversion rates by up to 35 % for paid search traffic (source S4).

The Bot Protection Agent detects invalid clicks in paid traffic and builds refund‑ready reports, allowing teams to reclaim up to 20 % of wasted ad spend (sources S4, S5, S6, S7).

With the Translation Agent, SeaText can display page content in up to 125 languages without maintaining separate sites, helping businesses reach new markets (source S4).

The Personalization Agent adapts copy based on visitor context, such as industry or account name, which can improve relevance for B2B outreach (source S5).

All of these agents rely on the same lightweight snippet, so the SSR configuration described earlier applies regardless of which features you enable.

FAQ

Does SeaText need a Node.js server?

No. The snippet is pure client‑side JavaScript. It works with any host that serves static HTML or SSR HTML — Netlify, Vercel, Cloudflare Pages, AWS Amplify, traditional VPS, etc.

Can I load SeaText via a module bundler instead of a raw snippet?

Not recommended. The snippet is designed to load asynchronously from the CDN with a stable version. Bundling it adds weight to your main chunk and removes the async guarantee.

What if my CSP uses nonces?

Generate a nonce for the inline snippet tag, or allow the SeaText CDN origin in script-src. The snippet itself is a single script src='https://cdn.seatext.com/seatext.js' async> tag, so a nonce on that tag satisfies strict CSP.

Will SeaText hurt my Lighthouse scores?

No. The script is under 15 KB, executes in <15 ms, and causes zero CLS. It typically has no measurable impact on Performance, Accessibility, or Best Practices scores.

Do I need to change anything for streaming SSR (React 18, Next.js 13+)?

No. The snippet sits in the shell HTML that streams first. It loads in parallel with the hydration chunks and runs after the DOM is ready.

How do I verify SeaText is working on an SSR page?

  1. Open the page in an incognito window.
  2. Open DevTools → Network and filter for the SeaText script. Confirm 200 OK.
  3. Open Console and look for the SeaText initialization log.
  4. Inspect a headline or CTA — you should see a data-seatext attribute or the rewritten text.

Can I use SeaText with edge middleware that rewrites HTML?

Yes, but ensure the middleware does not strip or defer the snippet. The snippet must remain in the final <body> that reaches the browser.

Further reading and comparison sources

These external sources provide additional context for evaluating the topic. Their inclusion is not an endorsement.

Learn more

Visit the website for more information.