[**CameraKit Web SDK - Push 2 Web v1.17.0**](../README.md)

***

[CameraKit Web SDK - Push 2 Web](../globals.md) / Push2Web

# Class: Push2Web

## Constructors

### new Push2Web()

> **new Push2Web**(): [`Push2Web`](Push2Web.md)

Create new instance of Push2Web object,
it can be used to start listening for the events,
subscribe or unsubscribe for notifications from Lens Studio.
Also provides the extension object for the @snap/camera-kit package.

#### Returns

[`Push2Web`](Push2Web.md)

## Properties

### events

> `readonly` **events**: `TypedEventTarget`\<[`Push2WebEvents`](../type-aliases/Push2WebEvents.md)\>

Use this property to subscribe for the different types of events that can occur during push 2 web execution.

Subscribe to `error` event to be aware if something has happened during the lens push,
with network communication or any other type of error,
event object also contains detailed explanation of the cause.

Use `subscriptionChanged` event to be aware when subscription state is changed.

Use `lensReceived` event to be aware when new lens is received from Lens Studio,
also you can get the additional details about the pushed lens.

#### Example

```ts
push2web.events.addEventListener('error', ({ detail }) => {
  if (detail.name === 'LensExcludedError') {
    console.log(`Lens is excluded from the push, by the following reason: ${detail.reason}.`)
  }
})
```

## Accessors

### extension

#### Get Signature

> **get** **extension**(): `ExtensionContainer`

The extension object must be passed to the Camera Kit object during its bootstrap process.
This is a requirement for the proper functioning of push to web functionality.

##### Example

```ts
import { bootstrapCameraKit } from "@snap/camera-kit";

const push2web = new Push2Web();
const extensions = (container) => container.provides(push2Web.extension);

const cameraKit = await bootstrapCameraKit({ apiToken: "token from developer portal" }, extensions);
const cameraKitSession = await cameraKit.createSession();
```

##### Returns

`ExtensionContainer`

## Methods

### subscribe()

> **subscribe**(`accessToken`, `cameraKitSession`, `repository`): [`SubscriptionInstance`](../type-aliases/SubscriptionInstance.md)

Initiate subscription for the events from Lens Studio.

#### Parameters

##### accessToken

`string`

After user will be logged in to the web page,
using Snapchat account, you can get access token from Login Kit.

##### cameraKitSession

`CameraKitSession`

Instance of CameraKitSession object form @snap/camera-kit package.

##### repository

`LensRepository`

Instance of LensRepository object from @snap/camera-kit package.

#### Returns

[`SubscriptionInstance`](../type-aliases/SubscriptionInstance.md)

#### Subscription Instance
