# Client Id in Hook is undefined

**URL:** <https://community.auth0.com/t/client-id-in-hook-is-undefined/50972>\
**Category:** Get Help\
**Tags:** clients, hooks, auth0\
**Created:** [October 5, 2020, 8:47am UTC](https://community.auth0.com/t/client-id-in-hook-is-undefined/50972 "2020-10-05T08:47:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![EMM](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/emm/32/14596_2.png) [@EMM](https://community.auth0.com/u/EMM)\
**Post date:** [October 5, 2020, 8:47am UTC](https://community.auth0.com/t/client-id-in-hook-is-undefined/50972/1 "2020-10-05T08:47:04Z")

</div>

We are using different clients and in some of the documentation we found that the context object in the Hook has the clientID property which you can check, e.g:

var url;  
if(context.clientID === ‘MY\_DEV\_CLIENT\_ID’){  
url = ‘[https://dev.myapp.com](https://dev.myapp.com)’;  
} else if (context.clientID === ‘MY\_PROD\_CLIENT\_ID’){  
url = ‘[https://myapp.com](https://myapp.com)’;  
}

But when we try this example, looks like the clientID is undefined. What can be the issue here?

---

<div class="post-metadata">

**Author:** ![john.gateley](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/john.gateley/32/10879_2.png) [@john.gateley](https://community.auth0.com/u/john.gateley)\
**Post date:** [October 5, 2020, 1:17pm UTC](https://community.auth0.com/t/client-id-in-hook-is-undefined/50972/2 "2020-10-05T13:17:40Z")

</div>

Hi @EMM

Try using the Realtime Webtask logs extension and console.log to help figure out what is going on.

John

---

<div class="post-metadata">

**Author:** ![EMM](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/emm/32/14596_2.png) [@EMM](https://community.auth0.com/u/EMM)\
**Post date:** [October 6, 2020, 8:59am UTC](https://community.auth0.com/t/client-id-in-hook-is-undefined/50972/3 "2020-10-06T08:59:20Z")

</div>

Hi @john.gateley Thanks for the quick response. I try that, debagging the Hook but seems like there is no property client Id in the object. That is way is undefined. Is it possible to get to the client Id in the Pre User Registration hooks?

---

<div class="post-metadata">

**Author:** ![john.gateley](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/john.gateley/32/10879_2.png) [@john.gateley](https://community.auth0.com/u/john.gateley)\
**Post date:** [October 6, 2020, 1:28pm UTC](https://community.auth0.com/t/client-id-in-hook-is-undefined/50972/4 "2020-10-06T13:28:49Z")

</div>

In hooks, use client.id, not context. client\_id

Create a new hook and look at the top, there’s a ton of parameter documentation that will help you out.  
After you look, you can delete the new hook you just created.

John

---

<div class="post-metadata">

**Author:** ![EMM](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/emm/32/14596_2.png) [@EMM](https://community.auth0.com/u/EMM)\
**Post date:** [October 7, 2020, 7:32am UTC](https://community.auth0.com/t/client-id-in-hook-is-undefined/50972/5 "2020-10-07T07:32:49Z")

</div>

Hi @john.gateley,

I’m using Pre User Registration hook, and the client object is not accessible there.  
I can only access the client object in the Client Credentials Exchange hook.  
Is there any option to get to the client id in the pre user registration hook?

Thanks,

---

<div class="post-metadata">

**Author:** ![john.gateley](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/john.gateley/32/10879_2.png) [@john.gateley](https://community.auth0.com/u/john.gateley)\
**Post date:** [October 7, 2020, 1:37pm UTC](https://community.auth0.com/t/client-id-in-hook-is-undefined/50972/6 "2020-10-07T13:37:06Z")

</div>

Hi @EMM

I suspect it is not available there. You do have the connection ID (a user signs up for a connection, not an application) and could use that and the management API to figure out which client IDs are available for that connection.

John

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [January 8, 2024, 10:41am UTC](https://community.auth0.com/t/client-id-in-hook-is-undefined/50972/7 "2024-01-08T10:41:29Z")

</div>

Hey there!

As this topic is related to Rules - Hooks - Actions and Rules & Hooks are being deprecated soon I’m excited to let you know about our next [Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team](https://community.auth0.com/t/auth0-community-ask-me-anything-rules-hooks-and-why-actions-matter/124043) on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!

[Learn more here!](https://community.auth0.com/t/auth0-community-ask-me-anything-rules-hooks-and-why-actions-matter/124043)
