# Generative UI custom authentication

**URL:** <https://forum.langchain.com/t/generative-ui-custom-authentication/582>\
**Category:** LangGraph\
**Tags:** cloud, js-help\
**Created:** [July 21, 2025, 5:31am UTC](https://forum.langchain.com/t/generative-ui-custom-authentication/582 "2025-07-21T05:31:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dileep-veya](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/dileep-veya/32/274_2.png) [@dileep-veya](https://forum.langchain.com/u/dileep-veya)\
**Post date:** [July 21, 2025, 5:31am UTC](https://forum.langchain.com/t/generative-ui-custom-authentication/582/1 "2025-07-21T05:31:23Z")

</div>

\*Im working on generative UI using langraph server and langrpah sdk.

- SDK not including bearer token for frontend javascript assets like entrypoint.css, entrypoint.js.

```auto
SDK Client creation

import { Client } from '@langchain/langgraph-sdk';
import { env } from '~/env';

export function createClient({ auth_token }: { auth_token: string }) {
  const client = new Client({
    apiUrl: env.NEXT_PUBLIC_LANGGRAPH_API_URL,
    defaultHeaders: { Authorization: `Bearer ${auth_token}` },
  });
  return client;
}

```

```auto
useStream initialisation

  const streamValue = useTypedStream({
    apiUrl,
    defaultHeaders: {
      "authorization": jwtToken
    },
    assistantId,
    threadId: threadId ?? null,
    onFinish(state) {
      if (state.values.promptSuggestions) {
        setPromptSuggestions(state.values.promptSuggestions);
      }
    },
    onCustomEvent: (event, options) => {
      if (isUIMessage(event) || isRemoveUIMessage(event)) {
        options.mutate((prev) => {
          const ui = uiMessageReducer(prev.ui ?? [], event);
          return { ...prev, ui };
        });
      }
    },
    onThreadId: (id) => {
      setThreadId(id);
      // Refetch threads list when thread ID changes.
      // Wait for some seconds before fetching so we're able to get the new thread that was created.
      sleep().then(() => refetch());
    },
  });

```

 ![screenshot](https://canada1.discourse-cdn.com/flex007/uploads/langchain/original/1X/3c7688453acba85f74a4c4f915bf0b416c5afbd5.png)
