guide · next.js app router
Add Bubblio to a Next.js app
Two small files and one edit. When you're done, a live support bubble sits in the corner of every page of your site. No expertise needed — each step below tells you exactly which file to open and highlights the lines you addin green.
where things go
Install the packages
In your project folder, run:
Put your API key in .env.local
Grab a key from your Bubblio dashboard → API Keys (it starts with bbl_). Open the file called .env.local in the root of your project — create it if it doesn't exist — and add one line:
This file stays on your computer and your server — it's never sent to visitors' browsers. That's the whole reason for step 2: the browser asks your server for a session, and only your server knows the key.
Create the session route (new file)
Create a new file at app/api/bubblio/session/route.ts (make the folders if they don't exist). Paste this — the entire file:
When a visitor opens the bubble, the widget calls this route, and this route asks Bubblio to start a live session on your account. Change the personality text to whoever your assistant should be.
Add the bubble to layout.tsx (two lines)
app/layout.tsx is the frame around every page of your site — anything you put there shows up everywhere. That makes it the right home for the bubble. Open it and add the two green lines; everything else is what a typical layout already looks like:
Only want it on one page instead of everywhere? Put those same two lines in that page's page.tsx instead.
npm run dev, open your site, and the bubble is in the bottom corner of every page — click it and say hello.Optional: answer with your data (tools)
Right now the assistant can talk, but it can't look anything up. Tools fix that: you declare a function name in the session route, and Bubblio calls your server whenever the assistant needs it — signed, so you know it's really Bubblio. Two changes:
Signature verification happens automatically — createBubblioToolRoute fetches your account's signing secret using the API key you already have. There is no second secret to copy. Every call the assistant makes shows up in your dashboard as it happens.