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

# Methods

<Note>When a method throws, compare `error.name` against the string values documented in [Error handling](/guides/library/error-handling).</Note>

## getUser

<code>getUser(): Promise\<<a href="/guides/library/types#user">User</a> | null></code>

Retrieves info about the current user. Returns `null` if the user is not logged in.

```typescript theme={null}
const user = await client.getUser();
```

##### Returns

```typescript theme={null}
{
    email: string; // user's email address

    // true if the user has comped access, an active lifetime purchase,
    // or a recurring active/trialing/past_due subscription whose current period has not ended
	paid: boolean;

    // true if the user can still start a free trial for this extension
	trial_available: boolean;

    // all plans the user has purchased
	plans: [
		{
			id: string,
			name: string,
			billing_cycle: "yearly" | "monthly" | "once",
			price: number,

			status: "active" | "trialing" | "past_due" | "canceled" | "unpaid" | "incomplete" | "incomplete_expired" | "paused",
			paid_at: string | null,
			trial_end: string | null,
			period_start: string | null,
			period_end: string | null,
			canceled_at: string | null,
		},
        ...
	];
}
```

## getTiers

<code>getTiers(): Promise\<<a href="/guides/library/types#tier">Tier</a>\[]></code>

Fetches all available tiers and their prices. You can call this before the user logs in, which is useful when your extension shows its own plans or pricing screen.

```typescript theme={null}
const tiers = await client.getTiers();
```

##### Returns

```typescript theme={null}
[
    {
        id: string,
        name: string,
        description: string | null,
        rank: number,
        trial_days: number | null,
        prices: [
            {
                id: string,
                billing_cycle: "yearly" | "monthly" | "once",
                price: number,
            },
            ...
        ],
    },
    ...
]
```

## openPricingPage

`openPricingPage(asPopup?: boolean): void`

Opens a page showing available subscription plans.

| Parameter | Type      | Default | Description                                                      |
| --------- | --------- | ------- | ---------------------------------------------------------------- |
| `asPopup` | `boolean` | `false` | If `true`, opens as a centered popup window instead of a new tab |

```typescript theme={null}
client.openPricingPage();

// or open as a popup window
client.openPricingPage(true);
```

<Frame>
  <img src="https://mintcdn.com/crxbase/MB_tPnzoKswHwvo9/images/openSubscriptionPopup.png?fit=max&auto=format&n=MB_tPnzoKswHwvo9&q=85&s=76cd8dcc69440d0bc54767827484a621" width="1920" height="1080" data-path="images/openSubscriptionPopup.png" />
</Frame>

## openCheckoutPage

`openCheckoutPage(priceId: string, asPopup?: boolean): void`

Opens the checkout page directly for a specific price. This is useful if you prefer to build your own custom plans UI in your extension (by using the `getTiers` method) and link directly to checkout, instead of using the crxbase pricing page.

| Parameter | Type      | Default | Description                                                      |
| --------- | --------- | ------- | ---------------------------------------------------------------- |
| `priceId` | `string`  | —       | The Tier Price ID to purchase                                    |
| `asPopup` | `boolean` | `false` | If `true`, opens as a centered popup window instead of a new tab |

```typescript theme={null}
// Open checkout for a price ID
client.openCheckoutPage("tp_12345");

// or open as a popup window
client.openCheckoutPage("tp_12345", true);
```

## openManagePage

`openManagePage(asPopup?: boolean): void`

Opens Stripe Portal to allow the user to manage their subscriptions.

| Parameter | Type      | Default | Description                                                      |
| --------- | --------- | ------- | ---------------------------------------------------------------- |
| `asPopup` | `boolean` | `false` | If `true`, opens as a centered popup window instead of a new tab |

```typescript theme={null}
client.openManagePage();

// or open as a popup window
client.openManagePage(true);
```

<Frame>
  <img src="https://mintcdn.com/crxbase/O04n9JR27o44w7RM/images/openManagePopup.png?fit=max&auto=format&n=O04n9JR27o44w7RM&q=85&s=c30460b7e6c85eedb5ee884f88630deb" width="1920" height="1080" data-path="images/openManagePopup.png" />
</Frame>

<Note>It is important you include a easy way to open this page inside your extension!</Note>

## openLoginPage

`openLoginPage(asPopup?: boolean): void`

Opens a page for the user to log in.

| Parameter | Type      | Default | Description                                                      |
| --------- | --------- | ------- | ---------------------------------------------------------------- |
| `asPopup` | `boolean` | `false` | If `true`, opens as a centered popup window instead of a new tab |

```typescript theme={null}
client.openLoginPage();

// or open as a popup window
client.openLoginPage(true);
```

<Frame>
  <img src="https://mintcdn.com/crxbase/MB_tPnzoKswHwvo9/images/openLoginPopup.png?fit=max&auto=format&n=MB_tPnzoKswHwvo9&q=85&s=9765b4ce8db725d7d45d680b7a67b34f" width="1920" height="1080" data-path="images/openLoginPopup.png" />
</Frame>

## logout

`logout(): Promise<void>`

Logs the current user out by clearing their authentication session.

```typescript theme={null}
await client.logout();
```
