A Guide for an Awesome Custom Auth0 Universal login
Tags: authentication, login, tutorial, auth0
Published: 2022-01-26 10:13:52

---
title: A Guide for an Awesome Custom Auth0 Universal login
published: true
description: A complete step by step guide to fully customize the auth0 login screen
tags: authentication, login, tutorial, auth0
cover_image: https://i.ibb.co/c6s29SZ/image.png
canonical_url: https://www.permit.io/blog/custom-auth0-universal-login
---

Your login and sign-up screens are the gateway to your app - the first thing a person sees before entering your actual application. So, they better look amazing, if you want an awesome app.

While creating our own login screen at Permit.io, I had to review and collect data from multiple different guides, so I finally decided to incorporate them into one unified guide that will help you transform your own login screen completely.

In this guide, we will cover:

- [5 reasons why you should customize the default Auth0 login](#5_reasons)

- [How to edit the default Auth0 login template](#default_login)

- [How to edit the Auth0 default title and description](#edit_default)

- [Which customization features are yet to be available](#unavailable)

Using Auth0 authentication has its advantages - It’s fast, secure, and highly functional. 
That being said, you can’t have the first thing your user sees when entering your app look like this: 


![Auth0 Default](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gor1u6wx8wlnzprzny4r.png)

</br>
<a name="5_reasons"></a>

##5 reasons why you should customize the default Auth0 login -


While functional, using the default Auth0 login screen has some key issues:

- While the login / sign-up screen is a crucial step in a user’s onboarding process, the default Auth0 login screen lacks some important elements - The company name is there, but the **overall look is different**. This makes the login screen seem like a **foreign entity inside your application**. And that’s not a good user experience. 

- The default option Auth0 provides in login through an **external domain** that belongs to Auth0, meaning each time someone wants to log in to use your application they are **redirected to a domain outside that of your company**. Your users might have no idea what Auth0 is, or why they are referred to this external website to provide their login information. This looks both unprofessional and unsecure. 

- This sense of unfamiliarity creates another issue: because the login screen doesn’t look like the rest of your company’s user interface, and it is based on a domain outside your company, **it can be easily interpreted by the user as a [phishing attack](https://auth0.com/blog/phishing-attacks-with-auth0-facts-first/)**.

- The message displayed reads: “Log in to ‘Company Name’ to continue to ‘Application Name’”. Not only is this not the most inviting message, changing it is no trivial task (As we will see later on).

- The login interface uses only a small percentage of your screen, the rest of it being just one color, making it look quite dull and uninviting on one of the most important screens in your entire app. 

While the good news is that most of these features are customizable, the bad news is that implementing these customizations is no easy feat, and far from intuitive. Hence this guide 😉
</br>
</br>
##What can we do about this?

Overcoming these issues took me a while, but we were very pleased with the end result:


![Finished Result](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m77d3eml74gn8fqw2dkh.png)


**So how did we get here? Let’s review the steps:**

</br>
##1. Enabling custom domains

As we have stated before, having your login/signup based in a domain outside your company creates various issues. Apart from that, Auth0 only allows you to customize your login screen by using a custom domain - which is a paid feature. 

To do this - 

- Choose the correct tenant (most likely production).

- In the left sidebar go to **Branding** > **Custom Domains**.
(If you haven’t upgraded your plan to include custom domain support, you will need to do that first).


![Custom Domain](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/peaa719787nxqwc7ywy7.png)

- Approve your custom domain through the instructions provided by Auth0 to prove that you actually own it (This includes adding some TXT entries to the domain).

- This is what an approved custom domain should look like (notice the **ready** status):

![Ready](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eayg9xm9wpe41hhbzeg3.png)

</br>
<a name="default_login"></a>

##2. Editing the login template

Now that we have a custom domain, we can get to editing the login screen itself. 

If you check out [Auth0’s documentation](https://auth0.com/docs/brand-and-customize/universal-login-page-templates) you will notice they suggest using POST requests to update the template. This means posting all of the code for the entire page every time we want to make the smallest of changes. That can be a huge hassle. 

To overcome this issue, I used [Auth0 CLI](https://github.com/auth0/auth0-cli) (That’s still in beta, but works *almost* perfectly) which utilizes [Storybook](https://storybook.js.org/). Auth0 CLI allows you to edit the login template from your code editor while previewing those changes in Storybook as you go along.
 
**How to do this:**

- Download Auth0 CLI:

On Mac:

```
brew tap auth0/auth0-cli && brew install auth0
```

On Linux:

```
brew tap auth0/auth0-cli && brew install auth0
```

On windows (With Scoop):

```
scoop bucket add auth0 https://github.com/auth0/scoop-auth0-cli.git 
⁠scoop install auth0
```

Check [this link](https://github.com/auth0/auth0-cli) for more options.
⁠

- Login to your account using the following command: 

`auth0 login`

- Run the following command: 

`auth0 branding templates update`

This will open your default code editor (I recommend [setting VSCode as your default editor](https://stackoverflow.com/a/36644561/1037613)), and a Storybook window in your browser, previewing the current state of your login screen. 

- When you make changes in your code editor, you see them updated live in the Storybook preview window. 


![Storybook Preview](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/btazd3t9u63xi10jnet5.png)

_This is how the StoryBook preview looks like_

- Remember to add `{%- auth0:head -%}` in the HTML head tag 
⁠and `{%- auth0:widget -%}` where you want the Auth0 widget to be injected. 

This is an example of a basic template that displays the Auth0 login, ([we also shared our full template at the end of this guide](#our_template)):

```
⁠html
<!DOCTYPE html><html>
  <head>
    {%- auth0:head -%}
  </head>
  <body>
    {%- auth0:widget -%}
  </body></html>

```


- When you close the editor, Auth0 CLI will ask you if you want to update the login template. 


![Approve](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/35xifmzii1j5oes0azyj.png)



- **Approve, and you’re done!**



**Important note:**
The authentication widget previewed on Storybook is not identical to the actual one that is going to appear on your website. These could also display a bit differently on mobile/different screens - so make sure to recheck everything in your real environment after updating your template. 


![Versus](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wnk9xk1jbfzcrxt7t4u1.png)


_Note the Storybook preview (Left) vs. the actual version (right)._

⁠</br>
<a name="edit_default"></a>

##3. Editing Auth0 widget default title and description
⁠In this part, I’ll explain how to change the default text templates provided in the Auth0 login screen through API management. The default text will look like this:

Log in to `Company Name’ to continue to ‘Application Name’

**To do this:**

- First, you will need to get your API management token: Go to
**Applications** > **APIs**, click on Auth0 Management API. Go to the API Explorer tag, and copy the token by clicking the copy icon on the right. 


![Copy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bwul1trqbiqrm7mi3s6v.png)


![APIs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6z1awlo8n799vritoiyo.png)


![API Managment](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qyuwzc70uabvz5llgr6i.png)

- Go to the [Auth0 “prompt: login” Documentation](https://auth0.com/docs/brand-and-customize/text-customization-new-universal-login/prompt-login), and get the names of the strings you want to change. For example, the key for the following login screen string:

`Log in to ${companyName} to continue to ${clientName}`

Is `description`.

- Go to “Set custom text for a specific prompt” in [Auth0’s API management docs](https://auth0.com/docs/api/management/v2#!/Prompts/put_custom_text_by_language).

- On the top left side of the screen, click “**Set API Token**”, and paste the API token you copied. 


![API Token](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hrxmhcpyauoo8vqbik1k.png)

- Select the prompt you would like to make changes to (in our case: login)

- Select the language (in our case: EN - English)

- Under “body” - add all of the changes you wish to make in this prompt (in our case: description and title) 



![Custom Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tmcr7enwynly2a9ua0nk.png)

**NOTE:** If you want to change more than one prompt, you have to make both changes first, and then save them together. If you do them separately the first will revert to its original state.

- Click **TRY** to save your changes.


![Try](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jones20x7yk6x4hzv5d4.png)


You may want to repeat this process to edit your signup widget as well. To do this, locate the text you want to change here, and repeat the process while choosing signup instead of login 
in all the steps.

</br>
<a name="unavailable"></a>

##4. Things you cannot do with Auth0 universal login

As of the writing of this guide, a feature to change the login widget to request the user to repeat the password on signup is not yet available. A [GitHub issue for this](https://github.com/auth0/lock/issues/61) has been open since 2014, yet no relevant action was taken.






**I hope this guide enabled you to set up your own authentication via Auth0. **

Usually, once you have authentication set up, the next step is to do authorization!
⁠Check out our blog post on the [5 best practices for building cloud-native permissions](https://www.permit.io/blog/5-best-practices-for-building-cloud-native-permissions), or visit [permit.io](permit.io) to learn more about getting permissions as a service.


<a name="our_template"></a>
You can check out our own template [on Github](https://gist.github.com/obsd/9f05d322a03f47d54b302754e9e000df)

---canonical_url:https://www.permit.io/blog/custom-auth0-universal-login