Skip to main content

Building Connected Lenses

The Lens Studio tools for building and testing Connected Lenses on SPECS: Sync Kit, session IDs, multiple Previews, the Connected Lens Monitor, and testing on several devices.

  • Snapchat: not supported
  • SPECS: fully supported
  • Camera Kit Web: not supported
  • Camera Kit Mobile: not supported
1 platform note
  • SnapchatNot supported
  • SPECSFully supported
  • Camera Kit WebNot supported
  • Camera Kit MobileNot supported

Platform details

  • Snapchat — Not supported. See Connected Framework

  • SPECS — Fully supported.

  • Camera Kit Web — Not supported.

  • Camera Kit Mobile — Not supported.

You build Connected Lenses for SPECS in Lens Studio. Lens Studio has tools for building and testing Connected Lenses in the editor and on SPECS; this page describes each one.

Sync Kit for Connected Lenses

Sync Kit (formerly Spectacles Sync Kit) is a Lens Studio package that provides the core logic, APIs, and components for building Connected Lenses on SPECS. To set up a project with Sync Kit, see the Sync Kit docs.

Check TypeScript compilation in the TypeScript Status panel

The Sync Kit package is written in TypeScript, which must compile before you can preview your Lens. To confirm that compilation is complete, open the TypeScript Status panel: Window > Utilities > TypeScript Status.

The Window menu open on Utilities, with TypeScript Status highlighted

Set the project's target platform to SPECS

Select File > Project Settings and set Target Platform to SPECS. A project created from a template for Snapchat targets Snapchat: Sync Kit still runs in the Preview panel, but the Lens builds for Snapchat until you change the target platform.

The Target Platform setting in Project Settings, set to SPECS

The Connected Lens Module and its Session ID

The Sync Kit package includes a Connected Lens Module, the asset that connects your Lens to the Connected Lenses backend. Select it in the Asset Browser to see its settings in the Inspector, including the Session ID field. The session ID is a unique string that identifies the session. Select Randomize Session ID to create a new session, or to reset the session for all Preview panels at once.

The Connected Lens Module in the Inspector, with Join Instantly, the Session ID field, and the Randomize Session ID button outlined

Use the same session ID in Lens Studio and on SPECS

Setting the same session ID in Lens Studio and on SPECS puts them in one session, which makes it faster to develop and test Connected Lenses. You no longer select a session by hand in Lens Studio, and you can test a Connected Lens with a single SPECS device: the device joins the same session as the Preview panels in Lens Studio.

  1. Find the session ID at the top of the Preview panel in Lens Studio.

    The top of a Preview panel running a Sync Kit Lens, with the Session line and its UUID outlined
  2. In the SPECS App, open Developer Settings, turn on Skip Session Selection, and enter the session ID.

With the same session ID set, a Lens launched on SPECS connects directly to that session, so users join it automatically instead of selecting a session.

Set the same session ID in the SPECS App for every SPECS device that should join the session.

The session ID must be a valid UUID (Universally Unique Identifier), such as 123e4567-e89b-12d3-a456-426614174000. The session ID is the key that puts devices in the same session, so a correctly formatted UUID keeps session management and communication between SPECS and Lens Studio reliable. To get a valid UUID, select Randomize Session ID in the Connected Lens Module: it generates one for you and avoids formatting errors.

Test a Connected Lens with multiple Preview panels

You can test a Connected Lens in Lens Studio with several Preview panels. Each Preview panel is a different user in the same Connected Lens session.

  1. To add a Preview panel to your layout, select Window > General > Preview.

    The Window menu open on General, with Preview highlighted
  2. In the new Preview panel's toolbar, open the device menu (the glasses icon) and select SPECS 27. A new Preview panel doesn't copy the simulation settings of the others; see Preview Lenses for SPECS for the rest of the setup.

    The Preview panel's device menu with SPECS 27 selected

Each Preview panel shows the session ID it is connected to. Compare them to check that the Preview panels joined the same session.

Two Preview panels side by side, both running the Lens on SPECS 27 and showing the same session ID

To leave the session from a Preview panel, select Reset (the circular arrow) in the panel's toolbar. The Lens restarts at the Start Menu. To restart every Preview panel in a fresh session, select Randomize Session ID in the Connected Lens Module instead: a Preview panel that you reset on its own rejoins the session while the others stay connected, so the session state doesn't fully reset.

The Preview panel toolbar with the Reset button circled in red, beside Pause Preview

Watch a session in the Connected Lens Monitor

The Connected Lens Monitor gives a real-time view of a Connected Lens session, including its messages and its Realtime Stores. To open it, select Window > Utilities > Connected Lens Monitor. Development Workflow describes how to use it.

The Connected Lens Monitor showing the Realtime Stores of a session with two Preview panels, each store with its owner and current values

Test a Connected Lens on SPECS

To test your Connected Lens on SPECS devices, connect them to Lens Studio, send the Lens to each device, and then join the session on each device.

Connect SPECS to Lens Studio

  1. Connect each SPECS device to Lens Studio; see Connect Lens Studio to SPECS.
  2. For several SPECS devices, pair each device with the SPECS App, and connect every device to Wi-Fi.

Send a Connected Lens to several SPECS from one computer

Lens Studio connects to one SPECS at a time, so send the Lens to each device in turn:

  1. Send the Lens to the connected SPECS device.
  2. In the menu beside Preview, select Switch to Another SPECS, then send the Lens again.
  3. Repeat for each device.

For more details, see Connect to another SPECS and Send a Lens to SPECS.

If one SPECS device doesn't see the session started on another, try this order:

  1. Send the Lens to the first SPECS device, switch to the second, and send the Lens to it.
  2. Start the Lens on the second device, start a new session, and complete colocation.
  3. On the first device, wait for the session to show in Active Nearby, or launch the Lens from Drafts and join the session.

Send a Connected Lens to several SPECS from several computers

  1. In each computer's Lens Studio, set the same Session ID in the Connected Lens Module before you send the Lens to SPECS. Lens Studio randomizes the session ID when it opens a project that has a Connected Lens Module, so set it again each time you open the project.

    The Connected Lens Module in the Inspector, with the Session ID field holding a UUID
  2. Send the Lens to each SPECS device from its own computer's Lens Studio.

Test a Connected Lens with SPECS and Lens Studio together

When a session ID is set and the Lens doesn't use a Connected Custom Location, join the session from SPECS first. Lens Studio can't build a map that SPECS can colocate against, so the SPECS device must complete colocation first. Once the SPECS device has colocated and joined the session, the Preview panels in Lens Studio can join with the same session ID for synchronized interactions.

Test a Connected Lens with several SPECS devices

  • To test with several people, start and join a session as described in Using Connected Lenses.
  • To test alone with several SPECS devices, turn on Colocate for Solo Development in the SPECS App's Developer Settings. The devices then colocate through mapping only, so you don't need to look at another person.

APIs that are restricted in Connected Lenses

When you build and use Connected Lenses, some APIs are restricted to protect users' privacy. For the list, see How Connected Lenses Work.