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

# Sign-in for your app

> Add email, Google or Apple sign-in to the app you build, using Newly Backend.

This page is about sign-in for **your app's users**. To sign in to Newly itself, see [Sign up and sign in](https://docs.newly.app/get-started/sign-in.md).

## Email and password

Ask the agent for accounts, for example: "Let people create an account with email and password and keep their notes private."

The agent adds [Newly Backend](https://docs.newly.app/backend/overview.md) if your app doesn't have it, then builds the sign-up and sign-in screens. Setting up a backend needs credits in your balance. Email and password sign-in works as soon as the backend is set up. There's nothing to configure.

Test it in your preview by creating an account, signing out and signing back in.

## Google and Apple sign-in

Google and Apple sign-in need credentials from your own Google or Apple developer account. Newly doesn't provide ready-made test credentials, so these buttons won't work until you add yours.

**1. Create the sign-in credentials**

For Google, create an OAuth client in Google Cloud. For Apple, set up Sign in with Apple in your Apple Developer account. Each provider gives you a client ID and a client secret. For Apple, the client secret is a signed token you create from a key in your Apple Developer account.

**2. Add them to the sign-in service**

Set the values as secrets on the sign-in service of your dev backend. In **Settings** then **Project** then **Backend secrets**, switch to **Sign-in** and **dev**, and add each one. Or use the newly CLI:

```bash theme={null}
newly secrets set GOOGLE_CLIENT_ID <value> --service auth
newly secrets set GOOGLE_CLIENT_SECRET <value> --service auth
```

For Apple, use `APPLE_CLIENT_ID` and `APPLE_CLIENT_SECRET`. Always include `--service auth`. The default service doesn't work.

**3. Redeploy the backend**

Secrets take effect on the next deploy. Ask the agent to redeploy your dev backend. If you deploy yourself with `newly deploy --env dev`, run `newly pull` first, because the command deploys the `backend/` folder on your computer.

**4. Ask the agent to add the buttons**

For example: "Add Sign in with Apple and Google sign-in." The agent adds the Apple button first, because the App Store expects Sign in with Apple when an app offers other social sign-in options.

Don't paste client secrets into the chat. The agent declines them. See [Production and secrets](https://docs.newly.app/backend/production-and-secrets.md) for how to install the tool, sign in and work with secrets.

> [!NOTE]
>
> These commands set secrets on your dev backend. For your released app, set the same secrets on production by adding `--env prod`, then deploy to production with **Deploy backend to prod** in Settings, or `newly deploy --env prod`. You need to be the project's owner or have **Admin** access. See [Production and secrets](https://docs.newly.app/backend/production-and-secrets.md).

## Emails for password reset and verification

Newly sends your app's sign-up verification and password reset emails from `no-reply@` your domain. You don't need Resend or another email provider, or an API key. Until your domain is verified for email, these emails don't go out.

Your app needs a domain that Newly has verified for email:

* **A domain bought through Newly** is set up for email automatically. It takes about 5 to 15 minutes after the purchase.
* **A domain you bought elsewhere:** open **Integrations**, then **Email**, and use **Use a domain you own**. Add the DNS records it shows where you manage your domain's DNS. If it still isn't verified after a few hours, check the records and press **Check now**.

If the emails don't arrive once the domain is verified, or your app sends them through Resend or another provider, ask the agent to switch your app's sign-in emails to Newly Email and deploy your backend. The agent only deploys dev. For a released app, deploy production yourself afterwards with **Update main from dev** and **Deploy backend to prod**, as the project's owner or an Admin. See [Production and secrets](https://docs.newly.app/backend/production-and-secrets.md#deploy-your-backend-to-production).

These emails count toward your app's daily email limit. If your app doesn't have a forgot-password screen yet, ask the agent to add one.

## Sign-in from a website you own

Sign-in already works from your previews and from your app on a phone. You don't need to change anything for that.

If your app also runs as a website on a domain you own, the sign-in service has to trust that address. Add just that one address to the `TRUSTED_ORIGINS` secret on the **auth** service, then redeploy. Never set it to `*`, which would let any website sign your users in.

> [!WARNING]
>
> Don't set the keys the platform manages, such as `DATABASE_URL`, `BETTER_AUTH_SECRET`, `JWKS_URL` or anything starting with `NEWLY_`. Setting `BETTER_AUTH_SECRET` signs out every user of your app.

## Screen order with sign-in and a paywall

When your app has sign-in, onboarding and a paywall, the agent puts them in a fixed order:

1. Sign-in
2. Onboarding
3. Paywall
4. Home

A paywall before sign-in would tie purchases to nobody, so the agent keeps this order even if you ask for a different one.

## Related

> [card] [Data, accounts and Newly Backend](https://docs.newly.app/backend/overview.md)
>
> What Newly Backend includes and when the agent adds it.

> [card] [Production and secrets](https://docs.newly.app/backend/production-and-secrets.md)
>
> Deploy to production and manage API keys.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.