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.
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
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
<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.Why is the widget not showing?
- Check
NEXT_PUBLIC_SMARTALEX_TENANT_IDis set. Browser variables need theNEXT_PUBLIC_prefix. - Works locally but not on Vercel: the variable is in
.env.localbut not in Vercel, so add it and redeploy. - If you set a strict Content Security Policy, allow
https://api.getsmartalex.cominscript-srcandconnect-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
Should I use beforeInteractive for the widget?
Should I use beforeInteractive for the widget?
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.Does it work with the Pages Router and static pages?
Does it work with the Pages Router and static pages?
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 widget works locally but not on Vercel. Why?
The widget works locally but not on Vercel. Why?
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.Do I need to redeploy when I restyle the widget?
Do I need to redeploy when I restyle the widget?
No. The widget reads its style, colours and agent from SmartAlex at load time, so changes in Agent Settings → Widget need no rebuild.
Related
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.

