The VibeView browser SDK draws a session’s device inside your own page: the video, touch, keyboard and device controls, with no VibeView page or frame around it. Use it when you want the device to be part of your product’s own interface and you draw every state yourself. If a ready-made page is enough, use the guest page instead (see The guest page): it needs no code in the browser.
Your server still does everything that needs a key. The browser only ever holds a collab credential for one session.
Get access
The SDK is the package @scriptx-com/vibeview-sdk. It is a private package: access is
given to partners as part of their agreement. Contact support@vibeview.io, and we grant
your organization access and send the one-time setup for your package manager. Tell us
which sites your page runs on (for example https://app.example.com): the browser calls
VibeView from your site, and we allow each site by name.
It works in browsers with WebCodecs or Media Source Extensions with H.264; see Browser Compatibility. Every option, event and device control is described in the JavaScript Device SDK Reference. This page covers only what is different for a partner’s session.
How the pieces fit
- Your server creates the session in the account and starts it (Create a session, Start a session).
- Your server mints a collab credential for it with role
controlorview(Show a session in a browser) and hands itstokenand the session’sidto your page. - Your page opens the session with the SDK, giving it the session id and the token.
- Your server ends the session when your user is done (End a session), or turns the credential off.
The token is a credential for that one session. It cannot create, start or end a session, and it never reaches your key, your account or any other session.
Open the session
With React:
import { VibeView } from '@scriptx-com/vibeview-sdk/react';
function Device({ sessionId, token }: { sessionId: string; token: string }) {
return (
<VibeView
key={token} // a new token opens the session again
apiUrl="https://vibeview.io/api/v1"
sessionId={sessionId} // the session's id, from your server
token={token} // the collab credential's token, from your server
onSessionEnded={(info) => showEnded(info?.reasonCode)}
onConnectionRevoked={() => askServerForNewToken()}
style={{ width: 375, height: 812 }}
/>
);
}
Without React:
import { VibeViewClient } from '@scriptx-com/vibeview-sdk';
const client = new VibeViewClient('#device', {
apiUrl: 'https://vibeview.io/api/v1',
sessionId, // the session's id, from your server
token, // the collab credential's token, from your server
});
client.on('session:ended', (info) => showEnded(info?.reasonCode));
client.on('session:failed', (error) => showCouldNotOpen(error));
client.on('connection:revoked', () => askServerForNewToken());
- Set
apiUrltohttps://vibeview.io/api/v1. The SDK’s default does not reach the API. - Give the SDK a session id and it connects to that session; it never creates one. Do not set
autoStart: starting a session is your server’s call. - A first connection that is refused (a wrong or expired token, a session that does not
exist) is reported as
session:failed.
What is different for your sessions
- The session object. The SDK’s session identifies your session by
sessionId(your session id). Its numericidanddeviceIdare not set. - The role decides what the browser can do. A
viewcredential watches; acontrolcredential also sends touch, keys, text, rotation and device settings. Mint the role you mean: the SDK cannot raise it. With aviewcredential, setreadOnlyon the SDK too, so your page does not offer input the session will ignore. - The session stays in its app. Home, the app switcher, Lock and Siri do nothing from the
browser, as described in
The session stays in its app. While the app is
being opened or brought back, the device takes no input: the SDK tells your page with
embed:app-not-readyandembed:app-ready(onEmbedAppNotReadyandonEmbedAppReadyin React), so you can show a waiting state. These report changes only, not the state at the moment your page connects: show the device as ready untilembed:app-not-readyarrives. A session your server created withconfined: falseis different: Home and the app switcher work from the browser, and there is no waiting state (see Sessions that can leave their app). - Guests count. Each browser connected with a credential counts against the account’s
collab_guests_per_session; a browser over it is refused. - Usage counts in the account. The session’s streaming time is the account’s, whichever browser shows it.
Keep the browser connected
A credential’s expires_at limits connecting, not watching: a browser that is already
connected stays connected until the session ends or you replace or turn off the credential.
After expires_at the browser can no longer connect or reconnect with that token, and if
its video drops then, it may not come back.
The SDK reconnects by itself after a short network loss. When it cannot connect any more it tells your page one of two things:
| Event | React | Meaning |
|---|---|---|
connection:revoked | onConnectionRevoked | The token no longer works: it expired, you turned the credential off or replaced it with regenerate: true, or the session has as many guests as it may. The SDK does not retry. |
connection:failed | The player shows “Connection lost” with a Reconnect button | The SDK’s own retries ran out. |
For sessions that outlive a credential, mint a fresh credential on your server before the
current one expires. When your page needs to connect again (a reload, or one of the two
events above), open the session with the newest token: a token cannot be swapped inside a
running player, so in React give <VibeView> a key that changes with the token, and
without React call client.destroy() and create a new client. Minting again does not
disconnect browsers that use an earlier credential, unless you send regenerate: true.
Know when it ended
The SDK tells your page when the session ends (session:ended, or onSessionEnded in
React). Its reason code is a hint for the page and can be missing. Your server gets the
record: the session.ended event with the session’s end_reason (see
End reasons). Use the event for anything you store or bill, and
the SDK’s callback as the signal to update the page.
Keep it private
- Never send your partner key or an account access token to a browser. The collab token is the only credential a page needs.
- Hand the token to one browser, over your own authenticated channel, and do not put it in a URL you log or share.
- Mint the shortest credential that suits the page, and turn the credential off when your user leaves.