# Authentication

### Unique SignIn modal

The SignIn modal will be called everytime it's needed (Connect button or interaction with auth-only features)

It will update with your data automatically but you can customize it the way you want in the `/components/layout/sign-in-modal.tsx` file.

<figure><img src="/files/NfrEVh3591VBdbN3qNNb" alt=""><figcaption><p>SignIn Modal</p></figcaption></figure>

### Setup

Fill your `.env` file:

{% code title=".env" %}

```bash
BETTER_AUTH_SECRET=
BETTER_AUTH_URL=http://localhost:3000
```

{% endcode %}

Enter any string or generate a unique one with this [Generator](https://shipped.club/free-tools/secret-password-generator).

### Social Authentication

Google Auth is already pre-implemented, simply follow this guide:

1. Create a new project on [Google Cloud](https://console.cloud.google.com/)
2. Access `APIS & Services` > `Credentials` > `Configure Consent Screen`
3. Fill in all the info.
4. Add `userinfo.email` and `userinfo.profile` to scope and Submit
5. On `Credentials`**,** click *Create Credentials* > *OAuth Client ID*
6. On `Web Application` add:
   1. `Authorized JavaScript Origins` > **<http://localhost:3000>** & **https\://\[YOURDOMAIN].com**
   2. `Authorized redirect URLs` > **<http://localhost:3000/api/auth/callback/google>** & **https\://\[YOURDOMAIN].com/api/auth/callback/google**
7. **Submit**
8. `OAuth Consent Screen` > *Publish App*

Finally, copy your Client ID and Client Secret to the `.env` file:

{% code title=".env" %}

```bash
# Google Auth
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
```

{% endcode %}

{% hint style="info" %}
If you need more social authentication options, Better Auth offers various providers including GitHub, Facebook, Apple, Discord, and more. Check the [Better Auth documentation](https://www.better-auth.com/docs/authentication/social) for the complete list.
{% endhint %}

#### Google Auth SignIn is now fully functional!

### Magic Link

{% hint style="info" %}
Traditional email/password authentication is becoming obsolete for obvious security reasons. Magic Links allows you not to store your users' passwords in your database, thus relieving you of responsibility.
{% endhint %}

To enable this option, you need an email SMTP server, provided here by Loops.

👉 Check the [Emails section](/features/emails.md) to get started.

#### Your email SignIn is now fully functional!

### Polar Integration

Better Auth now includes Polar integration for seamless payment flows:

{% code title=".env" %}

```bash
# Polar Configuration
POLAR_ACCESS_TOKEN=your_polar_access_token
POLAR_WEBHOOK_SECRET=your_polar_webhook_secret
```

{% endcode %}

**Features:**

* Automatic customer creation on signup
* Integrated checkout flows
* Customer portal access
* Webhook handling for payments


---

# Agent Instructions: 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:

```
GET https://docs.directoryfa.st/features/authentication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
