Skip to main content
Next.js loads the SmartAlex widget with the next/script Script component or with a small React component, and Vercel deploys it like any other change. Both put your agent on the page as a floating widget that visitors can talk or type to.
In the app: Agent Settings → Widget → Install → Install code. Switch on Show widget on my website in the same place.
The widget is a browser overlay that runs on the client after hydration. It behaves the same with the App Router or the Pages Router, and with static, server-rendered or ISR pages.

What do I need first?

1

Have an agent ready

Create an agent with the Create a new agent card on Home.
2

Copy your tenant ID

Open Agent Settings → Widget → Install → Install code. The data-tenant-id value is your tenant ID, and a connected AI app can fetch it too.
3

Store it in an environment variable

A value the browser needs must start with NEXT_PUBLIC_:
.env.local
The tag takes one attribute, data-tenant-id. The widget reads its style, colours and agent from SmartAlex when the page loads, so it is the same for every style.

How do I add it with next/script?

This is the usual route. next/script loads the widget once across page changes and keeps it out of the first render. Use strategy="afterInteractive".
Do not use strategy="beforeInteractive". It is for scripts the page cannot render without. Use afterInteractive, or lazyOnload to wait until the browser is idle.

How do I mount it only on some routes?

Use a React component when you want conditional mounting, for example only after a cookie consent flag is set. Mark the file "use client" in the App Router.
components/SmartAlexWidget.tsx
Render <SmartAlexWidget /> once near the root so it stays across route changes, and the cleanup removes the script when the component unmounts.

How do I deploy it on Vercel?

1

Set the variable

In the Vercel dashboard add NEXT_PUBLIC_SMARTALEX_TENANT_ID under Project settings → Environment Variables for each environment you deploy.
2

Deploy

Push to your connected branch or run vercel --prod. Nothing special is needed in next.config.js.
3

Check the deployed address

Open the deployment, look for the widget in the corner, and in DevTools check for a request to api.getsmartalex.com for smartalex-widget.js.
The diagram shows how the pieces fit.

Why is the widget not showing?

  • Check NEXT_PUBLIC_SMARTALEX_TENANT_ID is set. Browser variables need the NEXT_PUBLIC_ prefix.
  • Works locally but not on Vercel: the variable is in .env.local but not in Vercel, so add it and redeploy.
  • If you set a strict Content Security Policy, allow https://api.getsmartalex.com in script-src and connect-src, and check the browser console for any other blocked address.
  • Check Show widget on my website is on, and that your domain is in Allowed websites if you set that list.

Can my editor run SmartAlex too?

Yes. Connect your AI editor over MCP and ask it for the widget code or to list your agents. See Use SmartAlex with Claude Code or Cursor, v0 and Bolt.

Questions people ask

No. beforeInteractive is for scripts the page cannot render without. The widget is an overlay, so use afterInteractive, or lazyOnload to wait until the browser is idle.
Yes. The widget is a browser overlay that runs after hydration. It works the same with the App Router, the Pages Router, static pages, server rendering and ISR.
The environment variable is probably set in .env.local but not in Vercel. Add NEXT_PUBLIC_SMARTALEX_TENANT_ID under Project settings → Environment Variables, then redeploy.
No. The widget reads its style, colours and agent from SmartAlex at load time, so changes in Agent Settings → Widget need no rebuild.

Installing the widget

The full install guide and fixes.

Widgets

The five styles, colours and limits.

Cursor, v0 and Bolt

Generated the app with an AI builder.

MCP overview

Run your account from an AI app.
Last modified on November 27, 2026