> For the complete documentation index, see [llms.txt](https://docs.cotter.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cotter.app/quickstart-guides/react-magic-link-with-email-and-phone.md).

# React – Sign in with Email/Phone

Cotter's Magic Link authenticates your user using a link. It allows seamless, fast, and secure way for your user to login to your Web App. Follow this simple guide to see how it works!

![Add Magic Link Authentication in just a few minutes](/files/-MBrfjtocuzcysGXyr38)

### Step 1: Import Cotter as a dependency

```
yarn add cotter
```

### Step 2: Initialize Cotter and Show the Form

```javascript
import React, { useEffect, useState } from "react";
import Cotter from "cotter"; //  1️⃣  Import Cotter

function App() {
  const [payload, setpayload] = useState(null);

  //  2️⃣ Initialize and show the form
  useEffect(() => {
    var cotter = new Cotter(API_KEY_ID); // 👈 Specify your API KEY ID here
    cotter
      .withFormID("form_default") // Use customization for form "form_default"
      .signInWithLink() // use .signInWithOTP() to send an OTP
      .showEmailForm()  // use .showPhoneForm() to send magic link to a phone number 
      .then(response => {
        setpayload(response); // show the response in our state
      })
      .catch(err => console.log(err));
  }, []);

  return (
    <div>
      {/*  3️⃣  Put a <div> that will contain the form */}
      <div id="cotter-form-container" style={{ width: 300, height: 300 }} />
      
      <pre>{JSON.stringify(payload, null, 4)}</pre>
    </div>
  );
}

export default App;
```

[Create a free account and go to the dashboard](https://dev.cotter.app/) to get your `API_KEY_ID` .

1. Import Cotter
2. Call `signInWithLink` to use Magic Link or `signInWithOTP` to use OTP, followed by `showEmailForm` or `showPhoneForm`, and get the response as a promise.
3. Setup a `<div>` with `id="cotter-form-container"` that will contain the form.

{% hint style="info" %}
To send code/link via SMS or WhatsApp, you'll need to add some balance to you project in the [Dashboard](https://dev.cotter.app/).
{% endhint %}

### 🎉 **You're done!**

Here's a [working example of the React app that we just made](https://codesandbox.io/s/react-magic-link-complete-90vig?file=/src/App.js).

## ✏️ **Ready to setup & customize your login?** <a href="#ready-to-setup-and-customize-cotters-js-sdk" id="ready-to-setup-and-customize-cotters-js-sdk"></a>

### **Customize the Form**

Easily customize the form from [Cotter's Dashboard](https://dev.cotter.app/) > Branding.

### **Full JS SDK Reference**

{% content-ref url="/pages/-M0ROJn7tosL9qeumqFd" %}
[Sign In with Email/Phone Number](/sdk-reference/web/web-sdk-verify-email-phone.md)
{% endcontent-ref %}

## 👉 What's Next?

### Customize the Form

You can customize the form from the [Dashboard](https://dev.cotter.app/) > Branding. You can also [add Custom CSS](/sdk-reference/web/web-sdk-verify-email-phone/styling.md#adding-your-own-css).

### Add Additional Fields

[**Add Additional Fields**](/sdk-reference/web/web-sdk-verify-email-phone/older-sdk/advanced-customization.md#additional-fields) like Name, Address, etc to the login form.&#x20;

### **Register User to your Backend**

When the user successfully authenticated, send Cotter's response to your backend to either create a new user or log the user in. Learn how to send Cotter's response and verify it in your backend:

{% content-ref url="/pages/-MDcFwnPyQzT3MiP1tHe" %}
[Backend: Handling Response](/sdk-reference/backend-handling-response.md)
{% endcontent-ref %}


---

# 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.cotter.app/quickstart-guides/react-magic-link-with-email-and-phone.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.
