JavaScript in New Universal Login Liquid Template

Hello! Is there any way to load custom JavaScript into the New Universal Login Liquid template? I’ve tried adding tags which throws a console error, tried parsing through the Liquid documentation but couldn’t find a solution that worked?

I have since realized that its a bug with Storybook in that the tags throw an error. If i just update the template, it renders OK. I’m not sure if this would be a bug in auth0’s configuration of storybook, or storybook itself?

1 Like

Hi @nnikkhoui,

Welcome to the Auth0 Community!

You should be able to add custom JS using the page templates API. Can you give an example of what’s not working?

1 Like

Hi @dan.woda !

Yes so when using the Auth0 CLI to update my template via:

auth0 branding templates update

if i add <script></script> right before the closing <body> tag (Example)

	<body class="_widget-auto-layout">
    {% if prompt.name == "login" or prompt.name == "signup"  %} 
	<div class="prompt-wrapper">
	<div class="before-widget">
	{%- auth0:widget -%}
	</div>
        </div>
    {% else %}
        {%- auth0:widget -%}
    {% endif %} 
    <script type="text/javascript"></script>
  </body>

The UI that displays in storybook gives me the following error:
Screen Shot 2023-04-19 at 12.50.31 PM

When I ignore this error, and save my template anyway, the UI that is actually deployed and displayed is works as it should! For some reason, the <script></script> tags do not seem to work well with Storybook.

1 Like

@nnikkhoui,

I’m not familiar, what is storybook?

Storybook is a tool to display UI components!
its used by the Auth0 CLI to display what your current template will looks like (docs here)

2 Likes

Hi Nikki, here are two resources that will help you with inserting inline scripts to your templates:

Hope that helps! Also, be sure to update to version 1.0.0 the Auth0 CLI. It was recently released and packs a number of improvements and bug fixes, especially for the universal login template experience.

1 Like

Thanks @will.vedder! Let us know if there is anything else.

@will.vedder AH i totally missed that existing Auth0 post - thank you so much! was scratching my head over this for a long time. Thank you @dan.woda as well!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.