-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Introduce Waitlist component docs
- Loading branch information
1 parent
8d2f713
commit 8787324
Showing
6 changed files
with
474 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,233 @@ | ||
--- | ||
title: '`<Waitlist />` component' | ||
description: The <Waitlist /> component renders a waitlist form that allows users to join for early access to your application. | ||
--- | ||
|
||
![The \<Waitlist /> component renders a waitlist form that allows users to join for early access to your application.](/docs/images/ui-components/waitlist.svg) | ||
|
||
The `<Waitlist />` component renders a waitlist form that allows users to join for early access to your application. | ||
|
||
> [!NOTE] | ||
> The `<Waitlist />` component is only available in Core 2. If you are using Next.js is available after <code>@clerk/nextjs\@6.2.0</code> | ||
## Properties | ||
|
||
All props are optional. | ||
|
||
<Properties> | ||
- `appearance` | ||
- <code>[Appearance](/docs/customization/overview) | undefined</code> | ||
|
||
Optional object to style your components. Will only affect [Clerk components](/docs/components/overview) and not [Account Portal](/docs/customization/account-portal/overview) pages. | ||
|
||
--- | ||
|
||
- `afterJoinWaitlistUrl` | ||
- `string` | ||
|
||
Full URL or path to navigate to after joining the waitlist. | ||
|
||
--- | ||
|
||
- `signInUrl` | ||
- `string` | ||
|
||
Full URL or path to the sign in page. Use this property to provide the target of the 'Sign In' link that's rendered. It's recommended to use [NEXT\_PUBLIC\_CLERK\_SIGN\_IN\_URL](/docs/deployments/clerk-environment-variables#sign-in-and-sign-up-redirects) instead. | ||
</Properties> | ||
|
||
## Usage with frameworks | ||
|
||
The following example includes a basic implementation of the `<Waitlist />` component. You can use this as a starting point for your own implementation. | ||
|
||
<Tabs items={["Next.js", "React"]}> | ||
<Tab> | ||
<CodeBlockTabs options={["App Router", "Pages Router"]}> | ||
```jsx {{ filename: '/app/waitlist/[[...waitlist]]/page.tsx' }} | ||
import { Waitlist } from '@clerk/nextjs' | ||
|
||
export default function WaitlistPage() { | ||
return <Waitlist /> | ||
} | ||
``` | ||
|
||
```jsx {{ filename: '/pages/waitlist/[[...index]].tsx' }} | ||
import { Waitlist } from '@clerk/nextjs' | ||
|
||
export default function WaitlistPage() { | ||
return <Waitlist /> | ||
} | ||
``` | ||
</CodeBlockTabs> | ||
</Tab> | ||
|
||
<Tab> | ||
```jsx {{ filename: '/waitlist.tsx' }} | ||
import { Waitlist } from '@clerk/clerk-react' | ||
|
||
export default function WaitlistPage() { | ||
return <Waitlist /> | ||
} | ||
``` | ||
</Tab> | ||
</Tabs> | ||
|
||
## Usage with JavaScript | ||
|
||
The following methods available on an instance of the [`Clerk`](/docs/references/javascript/clerk/clerk) class are used to render and control the `<Waitlist />` component: | ||
|
||
- [`mountWaitlist()`](#mount-waitlist) | ||
- [`unmountWaitlist()`](#unmount-waitlist) | ||
- [`openWaitlist()`](#open-waitlist) | ||
- [`closeWaitlist()`](#close-waitlist) | ||
|
||
The following examples assume that you have followed the [quickstart](/docs/quickstarts/javascript) in order to add Clerk to your JavaScript application. | ||
|
||
### <code>mount<wbr />Waitlist()</code> | ||
|
||
Render the `<Waitlist />` component to an HTML `<div>` element. | ||
|
||
```typescript | ||
function mountWaitlist(node: HTMLDivElement, props?: WaitlistProps): void | ||
``` | ||
|
||
### <code>mount<wbr />Waitlist()</code> params | ||
|
||
<Properties> | ||
- `node` | ||
- [`HTMLDivElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLDivElement) | ||
|
||
The `<div>` element used to render in the `<Waitlist />` component | ||
|
||
--- | ||
|
||
- `props?` | ||
- [`WaitlistProps`](#properties) | ||
|
||
The properties to pass to the `<Waitlist />` component | ||
</Properties> | ||
|
||
#### `mountWaitlist()` usage | ||
|
||
```js {{ filename: 'main.js', mark: [13] }} | ||
import { Clerk } from '@clerk/clerk-js' | ||
// Initialize Clerk with your Clerk publishable key | ||
const clerk = new Clerk('{{pub_key}}') | ||
await clerk.load() | ||
document.getElementById('app').innerHTML = ` | ||
<div id="waitlist"></div> | ||
` | ||
const waitlistDiv = document.getElementById('waitlist') | ||
clerk.mountWaitlist(waitlistDiv) | ||
``` | ||
|
||
### <code>unmount<wbr />Waitlist()</code> | ||
|
||
Unmount and run cleanup on an existing `<Waitlist />` component instance. | ||
|
||
```typescript | ||
function unmountWaitlist(node: HTMLDivElement): void | ||
``` | ||
|
||
#### `unmountWaitlist()` params | ||
|
||
<Properties> | ||
- `node` | ||
- [`HTMLDivElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLDivElement) | ||
|
||
The container `<div>` element with a rendered `<Waitlist />` component instance | ||
</Properties> | ||
|
||
#### `unmountWaitlist()` usage | ||
|
||
```js {{ filename: 'main.js', mark: [17] }} | ||
import { Clerk } from '@clerk/clerk-js' | ||
// Initialize Clerk with your Clerk publishable key | ||
const clerk = new Clerk('{{pub_key}}') | ||
await clerk.load() | ||
document.getElementById('app').innerHTML = ` | ||
<div id="waitlist"></div> | ||
` | ||
const waitlistDiv = document.getElementById('waitlist') | ||
clerk.mountWaitlist(waitlistDiv) | ||
// ... | ||
clerk.unmountWaitlist(waitlistDiv) | ||
``` | ||
|
||
### `openWaitlist()` | ||
|
||
Opens the `<Waitlist />` component as an overlay at the root of your HTML `body` element. | ||
|
||
```typescript | ||
function openWaitlist(props?: WaitlistProps): void | ||
``` | ||
|
||
#### `openWaitlist()` params | ||
|
||
<Properties> | ||
- `props?` | ||
- [`WaitlistProps`](#properties) | ||
|
||
The properties to pass to the `<Waitlist />` component | ||
</Properties> | ||
|
||
#### `openWaitlist()` usage | ||
|
||
```js {{ filename: 'main.js', mark: [13] }} | ||
import { Clerk } from '@clerk/clerk-js' | ||
// Initialize Clerk with your Clerk publishable key | ||
const clerk = new Clerk('{{pub_key}}') | ||
await clerk.load() | ||
document.getElementById('app').innerHTML = ` | ||
<div id="waitlist"></div> | ||
` | ||
const waitlistDiv = document.getElementById('waitlist') | ||
clerk.openWaitlist(waitlistDiv) | ||
``` | ||
|
||
### `closeWaitlist()` | ||
|
||
Closes the waitlist overlay. | ||
|
||
```typescript | ||
function closeWaitlist(): void | ||
``` | ||
|
||
#### `closeWaitlist()` usage | ||
|
||
```js {{ filename: 'main.js', mark: [17] }} | ||
import { Clerk } from '@clerk/clerk-js' | ||
// Initialize Clerk with your Clerk publishable key | ||
const clerk = new Clerk('{{pub_key}}') | ||
await clerk.load() | ||
document.getElementById('app').innerHTML = ` | ||
<div id="waitlist"></div> | ||
` | ||
const waitlistDiv = document.getElementById('waitlist') | ||
clerk.openWaitlist(waitlistDiv) | ||
// ... | ||
clerk.closeWaitlist(waitlistDiv) | ||
``` | ||
|
||
## Customization | ||
|
||
To learn about how to customize Clerk components, see the [customization documentation](/docs/customization/overview). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
--- | ||
title: Waitlist methods | ||
description: Explore methods on the Clerk class that allow you to add users to your waitlist. | ||
--- | ||
|
||
These methods on the [`Clerk`](/docs/references/javascript/clerk/clerk) class allow you to add users to your [waitlist](/docs/authentication/configuration/restrictions#waitlist). | ||
|
||
The following example assume: | ||
|
||
- you have followed the [quickstart](/docs/quickstarts/javascript) in order to add Clerk to your JavaScript application | ||
- you have set your sign-up mode to [**Waitlist**](docs/authentication/configuration/restrictions#waitlist) | ||
|
||
## `joinWaitlist()` | ||
|
||
Create a new waitlist entry programatically. | ||
|
||
```typescript | ||
function joinWaitlist({ emailAddress }: JoinWaitlistParams): Promise<Waitlist> | ||
``` | ||
|
||
### Parameters | ||
|
||
<Properties> | ||
- `emailAddress` | ||
- `string` | ||
|
||
The email address of the user you want to add in the waitlist | ||
</Properties> | ||
|
||
### Example | ||
|
||
<Tabs items={['NPM module']}> | ||
<Tab> | ||
<CodeBlockTabs options={["main.js", "index.html"]}> | ||
```js {{ filename: 'main.js', mark: [[9, 12]] }} | ||
import { Clerk } from '@clerk/clerk-js' | ||
|
||
// Initialize Clerk with your Clerk publishable key | ||
const clerk = new Clerk('{{pub_key}}') | ||
await clerk.load() | ||
|
||
const joinWaitlistButton = document.getElementById('join-waitlist-button') | ||
joinWaitlistButton.addEventListener('click', () => { | ||
clerk | ||
.joinWaitlist({ emailAddress: '[email protected]' }) | ||
.then((res) => console.log(res)) | ||
.catch((error) => console.log('An error occurred:', error.errors)) | ||
}) | ||
``` | ||
|
||
```html {{ filename: 'index.html' }} | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Clerk + JavaScript App</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<button id="join-waitlist-button">Join Waitlist</button> | ||
<script type="module" src="/main.js"></script> | ||
</body> | ||
</html> | ||
``` | ||
</CodeBlockTabs> | ||
</Tab> | ||
</Tabs> |
Oops, something went wrong.