# Personalize a Next.js or React site without new code

> Change what each visitor sees on a Next.js or React site from a dashboard, without a deploy for every change and without the page flickering.

Guides · Published 2026-11-16

Personalizing a Next.js or React site usually means code: a condition in a component, a deploy, and another deploy for every wording change. With one script tag in your layout, rules can change what each visitor sees from a dashboard instead, with no deploy per change. The one thing to get right is where the tag goes, so changes land before the page paints.

## Where the tag goes

**Next.js, App Router:** in the `<head>` of your root layout, `app/layout.tsx`. Use a plain `<script>`, not `next/script`: its default `afterInteractive` strategy, and `lazyOnload`, run the tag after the page has painted, which is exactly what you want to avoid. Next.js's ESLint config warns about synchronous scripts; here that's intentional ([Install on Next.js](https://geoengage.app/docs/install/nextjs)).

**Next.js, Pages Router:** in `pages/_document.tsx`, inside `<Head>`.

**React with Vite or Create React App:** in the `<head>` of the `index.html` your build serves, above your app's own script ([Install on React](https://geoengage.app/docs/install/react)).

Don't add the tag from a component, with `useEffect`, React Helmet or a script-loading hook. By the time a component runs, React has already painted the page.

## Routing is handled

Next.js, React Router and most other routers change the URL through the browser's History API, which the widget follows. On every route change it removes the previous page's popups and banners, checks your rules again, and records a page view. Nothing to set up ([Single-page apps](https://geoengage.app/docs/widget/single-page-apps)).

## Server rendering stays the same

Your server sends every visitor the same HTML, so your caching and server components don't change. Rules run in the visitor's browser, on the page your server already built.

## Use what your app knows

Your app knows things a rule can't see on its own: whether someone is signed in, their plan, their role. Tell GeoEngage with `setAttributes`, and target them with the **Visitor Attribute** condition ([Customer data conditions](https://geoengage.app/docs/rules/conditions#customer-data)):

```js title="after sign-in"
window.GeoEngage?.setAttributes({ plan: 'free' });
```

Then a rule such as **Visitor Attribute** `plan` is `free` can show an upgrade banner to free users only. Call `identify(email)` when someone signs in, and `clearIdentity()` when they sign out ([Identity and storage](https://geoengage.app/docs/widget/storage#identifying-visitors)).

## Build a first rule

1. Create a rule. Under **When visitor matches**, add **First Visit** is `false`.
2. Choose **Show Banner** and write *Welcome back: pick up where you left off*.
3. Choose **Save & Publish**. No build, no deploy.

[Try this rule in the GeoEngage rule builder](https://geoengage.app/try), no account needed.

## Check that it helped

Make a goal for what success means in your app, such as reaching the dashboard after sign-up. Your code can report it with `GeoEngage.trackConversion('signup')` ([Goals and conversions](https://geoengage.app/docs/analytics/goals)). Then test rules with **A/B Testing** on that goal ([A/B tests](https://geoengage.app/docs/rules/ab-tests)).

## Common questions

### Won't React re-render over a change?

Test any rule that changes an element your components re-render often. Banners, bars and popups are added beside your page, so React doesn't touch them.

### Does it work with server components?

Yes. Rules run in the browser on the HTML your server sent, whatever rendered it.

---

Source: https://geoengage.app/blog/personalize-nextjs-react-without-new-code
