> ## Documentation Index
> Fetch the complete documentation index at: https://auth0-docs-ia-custom-database-connections.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom Database Connections

> Use a custom database connection to connect Auth0 to your external user store for authentication, migration, or multi-tenant architectures.

Custom database connections let you connect Auth0 to an external user store. This supports use cases like:

* **Authenticating users using your own external user store** as the identity provider instead of Auth0's user store.

  In this application, after a user's first successful login authenticating with the external user store, Auth0 creates a [user account](/docs/manage-users/user-accounts) but does not store a hash of their passwords and never authenticates users with the Auth0 user store.

* **Incrementally [migrating users](/docs/manage-users/user-migration/configure-automatic-migration-from-your-database) to Auth0** from your external user store (sometimes called *trickle* or *lazy* migration).

  In this application, when a user tries to log in, Auth0 always tries to authenticate them with the Auth0 user store first. If the user does not exist there, Auth0 tries to authenticate them with the external user store and, if successful, creates the user in the Auth0 user store with the same ID and password used to log in.

* **Proxying access to an Auth0 tenant** in [multi-tenant architecture scenarios](/docs/get-started/auth0-overview/create-tenants/multi-tenant-apps-best-practices).

<Accordion title="See an example infrastructure diagram with Universal Login">
  For example, as part of the <Tooltip tip="Universal Login: Your application redirects to Universal Login, hosted on Auth0's Authorization Server, to verify a user's identity." cta="View Glossary" href="/docs/glossary?term=Universal+Login">Universal Login</Tooltip> workflow, custom database connections obtain user identity information from your external user store:

  <Frame>
    <img src="https://mintlify.s3.us-west-1.amazonaws.com/auth0-docs-ia-custom-database-connections/docs/images/cdy7uua7fh8z/2lHqvZKFiEbAXURU2gmchc/626cac94211c266f2135a41456b2e49d/custom-database-connections.png" alt="Custom Database Connections Anatomy" />
  </Frame>
</Accordion>

You control how Auth0 interfaces with your external user store by writing [database action scripts](/docs/authenticate/database-connections/custom-db/custom-database-connections-scripts), which are Node.js functions that Auth0 calls during functionality like logins and password changes.

You can customize the behavior of database action scripts to suit your specific use case. We provide several templates for each database action script to help you get started.
