> ## Documentation Index
> Fetch the complete documentation index at: https://docs.seasonlabs.co/llms.txt
> Use this file to discover all available pages before exploring further.

# EraWeb client

> Create the Web SDK client and manage a browser visitor.

## Create a client

```typescript theme={null}
import { EraWeb } from "@seasonlabs/era-web";

const eraWeb = new EraWeb({
  baseUrl: "https://your-era-endpoint.com",
  publishableKey: "your_publishable_key",
});
```

<ParamField path="baseUrl" type="string" required>
  Base URL of the Era service.
</ParamField>

<ParamField path="publishableKey" type="string" required>
  Publishable key for browser identity and verification requests.
</ParamField>

See [all Web SDK types](/web-sdk/types).

## `init(visitorId?)`

Loads the stored visitor or creates one.

```typescript theme={null}
init(visitorId?: string): Promise<string>
```

The returned ID starts with `era_vid_`.

Pass a lowercase UUIDv4 when your application already has a visitor UUID:

```typescript theme={null}
const visitorId = await eraWeb.init(
  "22222222-2222-4222-8222-222222222222",
);
// "era_vid_22222222-2222-4222-8222-222222222222"
```

The SDK validates the value, adds the prefix, stores it, and returns the
canonical ID.

## `getVisitorId()`

Reads the current visitor without creating one.

```typescript theme={null}
getVisitorId(): string | null
```

Returns the stored or in-memory visitor, or `null` when none exists.

## `getVerification()`

Checks whether the current visitor is linked to an Era end user.

```typescript theme={null}
getVerification(): Promise<VerificationStatus>
```

```typescript theme={null}
const { eraEndUserId } = await eraWeb.getVerification();
```

`eraEndUserId` is an opaque Era ID or `null`. It is not proof that the user is
signed in to your application.

## `startVerification(type, identifier)`

Sends an email or phone verification code.

```typescript theme={null}
startVerification(
  type: "email" | "phone",
  identifier: string,
): Promise<VerificationChallenge>
```

```typescript theme={null}
const challenge = await eraWeb.startVerification(
  "email",
  "person@example.com",
);
```

Use E.164 format for phone numbers.

## `confirmVerification(challengeId, code)`

Confirms a code and links the current visitor.

```typescript theme={null}
confirmVerification(
  challengeId: string,
  code: string,
): Promise<VerificationConfirmation>
```

```typescript theme={null}
const result = await eraWeb.confirmVerification(
  challenge.challengeId,
  code,
);

console.log(result.verified);     // true
console.log(result.eraEndUserId); // opaque Era ID
```

## `resendVerification(challengeId)`

Sends another code.

```typescript theme={null}
resendVerification(
  challengeId: string,
): Promise<VerificationChallenge>
```

Use the returned challenge for the next confirm or resend call. Its ID and
expiry can change.

## `resetVisitor()`

Replaces the current visitor and returns the new ID.

```typescript theme={null}
resetVisitor(): Promise<string>
```

Use this after logout, account switching, or a shared-device user change.
Operations that cross the reset boundary reject with error code
`visitor_reset`.

## Storage

The SDK stores the visitor in `localStorage` under:

```text theme={null}
era:visitor_id:<partnerId>
```

If browser storage is unavailable, the visitor remains in memory for the
current page. SDK instances for the same partner share the current visitor, and
open tabs synchronize changes through browser storage events.

See [Web SDK errors](/web-sdk/errors).
