> For the complete documentation index, see [llms.txt](https://docs.shipped.club/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.shipped.club/components/waitlist.md).

# Waitlist

This component can be used for a waitlist landing page, or to collect the email of users for your newsletter (just update the copy).

<figure><img src="/files/G11rCersUOS4x5LpThAD" alt=""><figcaption><p>Email collection</p></figcaption></figure>

When the user hits the "Remind me" button, we call the `/api/waitlist` endpoint.

To set up the email collection service, open `src/app/api/waitlist/route.ts`&#x20;

Component: `<Waitlist />`\
File: `src/components/Waitlist/Waitlist.tsx`

{% code title="page.tsx" %}

```typescript
import { Waitlist } from "@/components/Waitlist/Waitlist";
```

{% endcode %}

### MailChimp

Remember to set the environment variable `MAILCHIMP_AUDIENCE_LIST_ID` into the `.env` file (or your online service like Vercel, Netlify, Render, etc).

Add this code to `src/app/api/waitlist/route.ts`

```typescript
import { addMailChimpListMember } from "@/libs/mailchimp";
import type { NextApiRequest, NextApiResponse } from "next";

type ResponseData = {
  result: boolean;
};

export async function POST(req: Request) {
  const body = await req.json();
  const email = body.email;
  if (email) {
    addMailChimpListMember({
      email,
      firstName: "",
      lastName: "",
      tags: ["waitlits"],
    }); 
  }

  return Response.json({ result: true });
}
```

***

### Loops

Remember to set the environment variable `LOOPS_API_KEY` into the `.env` file (or your online service like Vercel, Netlify, Render, etc).

Add this code to `src/app/api/waitlist/route.ts`&#x20;

```typescript
import { createLoopsContact } from "@/libs/loops";
import type { NextApiRequest, NextApiResponse } from "next";

type ResponseData = {
  result: boolean;
};

export async function POST(req: Request) {
  const body = await req.json();
  const email = body.email;
  if (email) {
    createLoopsContact({
      email,
      firstName: "",
      lastName: "",
      userGroup: "Waitlist",
    }); 
  }

  return Response.json({ result: true });
}
```

***

### Enable reCaptcha

When you launch a waitlist, it is usually public.

This means that your website and the waitlist endpoint is subject to abuse by someone with malicious intent.

To prevent this, the waitlist form and endpoint comes with support to reCaptcha by Google, which is preset by default.

\
These are the instructions to correctly configure it.

* Visit <https://www.google.com/recaptcha>
* Create a project and add your domain and `localhost` for local development
* Copy the captcha site key and captcha secret key values and use them in the `.env` file:

{% code title=".env" %}

```properties
NEXT_PUBLIC_RECAPTCHA_SITE_KEY=""
RECAPTCHA_SECRET_KEY=""
```

{% endcode %}

* Finally, open `src/app/layout.tsx` and uncomment the script HTML tag that includes <https://www.google.com/recaptcha/api.js>

{% code title="src/app/layout.tsx" %}

```tsx
<script
    defer
    type="text/javascript"
    src={`https://www.google.com/recaptcha/api.js?render=${process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY}`}
/>
```

{% endcode %}

ReCaptcha should now work correctly.

***

{% hint style="info" %}
If you need basic components like buttons, inputs, etc, they are all available with [ChakraUI](https://chakra-ui.com/).
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.shipped.club/components/waitlist.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
