What is a session?
A session is an authenticated connection that allows your JavaScript code to communicate with mobile devices. Sessions are created programmatically using your OAuth client credentials and enable secure, real-time bidirectional communication.Creating sessions
Sessions are created programmatically in your code using your OAuth client credentials. The session is automatically scoped to the project the client belongs to.1
Get your credentials
Create an OAuth client in Uplink Console and copy its client ID and secret. See Authentication for the full walkthrough.
2
Create a session in code
Use the
uplink.session() method to create a session with your credentials:3
Connect a client to the session
Create a client from your session to interact with connected devices:
4
Deliver the session to your device
The
session object exposes two URLs for connecting a device. Use the one that matches your integration:- Connect app
- Native SDK
Display
session.qrUrl as a QR code in your UI. When your user scans it, the Uplink Connect app opens and joins the session automatically.The session object
uplink.session() and uplink.getSession() both
resolve to the same shape:
credential and keys are optional because neither is always present: getSession() never
returns credential, and keys only appears for the key types you requested via
include: { ecdh: true, ecdsa: true }.
Session security
Sessions are authenticated with your OAuth client credentials, which provide:- Project identity: Each OAuth client belongs to exactly one project — sessions created with it are scoped to that project automatically.
- Secure communication: Encrypted connections between your code and devices
- Access control: Manage permissions through Console settings
Session restriction
Every session is also bound to a secret verifier, so that holding a session’s URL is not enough to drive it. When you create a session, the SDK derives a challenge from the verifier and sends only the challenge to Uplink — the verifier itself never leaves your process. When a client connects, it presents the verifier as itscredential. A client that presents the
matching credential can discover paired devices and open connections to them. A client that does
not still connects, but device discovery and connection setup are blocked for it.
You do not opt in to this. If you do not supply a verifier, uplink.session() generates one for
you, and either way it comes back on the session as credential:
restrict: { verifier } does not turn restriction on. It only replaces the generated
value with one you chose, so you can reproduce it later:
uplink.client.fromSession() reads credential
off the session object and passes it along for you. It only becomes something you manage when
you connect from a different runtime than the one that created the session.
Reconnecting from another runtime
uplink.getSession() refetches a session you created
earlier — a fresh sessionUrl, the qrUrl, and optionally the keys. It never returns
credential. Uplink stores only the challenge, so it cannot give the verifier back to you even
in principle.
That leaves two ways to reconnect, both of which come down to having the verifier on hand.
Persist the credential you were given. Store session.credential alongside
session.sessionId when you create the session, then merge it back in before connecting:
sessionId:
- Treat it like a password. Anyone who has it, plus the session’s URL, can drive the session.
- Use a high-entropy value — a UUID or a random 32-byte string — not a guessable name.
- Uplink cannot recover it for you. If you lose the verifier for a session you intended to reconnect to, create a new session.
- A verifier belongs to one session. Reusing one across sessions gains you nothing and widens the blast radius if it leaks.
Keep the verifier out of anything you show a user.
session.qrUrl is the only URL a user ever
needs — the credential is strictly between your code and Uplink.Session lifecycle
Connection
When you connect to a session, the client establishes a WebSocket connection to the Uplink relay server:Active session
During an active session:- Devices can connect and disconnect
- Browsers can be launched and managed
- Commands are sent in real-time
- Events are emitted for device state changes
Closing a session
Always close the client when you’re done to properly clean up resources:Session expiration
Sessions end when:- The connection is closed by the client (
client.close()) - The session is terminated in the Console
- The OAuth client used to create the session is disabled or deleted
- Network connectivity is lost
Multi-session patterns
Load distribution
For high-volume automation, distribute load across multiple sessions:Next steps
Device management
Learn how to manage devices in sessions
Client API
Explore the Client API reference