LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
React SDK
Vue SDK
Svelte SDK
Angular SDK
LangGraph SDK
  • Ui
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Utils
  • Server
  • Stream
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
  • Store
LangGraph Checkpoint Redis
  • Shallow
  • Store
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
  • Cli
LangGraph API
LangGraph CLI
LangGraph CUA
  • Utils
LangGraph Supervisor
LangGraph Swarm
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangGraph
WebChannelsPregelPrebuiltRemote
React SDK
Vue SDK
Svelte SDK
Angular SDK
LangGraph SDK
UiClientAuthReactLoggingReact UiUtilsServerStream
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
Store
LangGraph Checkpoint Redis
ShallowStore
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
Cli
LangGraph API
LangGraph CLI
LangGraph CUA
Utils
LangGraph Supervisor
LangGraph Swarm
Language
Theme
JavaScript@langchain/reactuseMediaURL
Function●Since v1.0

useMediaURL

Resolve the lazy MediaBase.objectURL promise into a string suitable for direct use in <audio src> / <img src> / <video src> / <a href download>. Returns undefined until the URL is available.

Lifecycle:

  • On mount (or when media changes) the hook awaits media.objectURL, then commits the resolved string to state.
  • On unmount (or when media changes) the hook calls media.revoke() to free the object URL slot. The next consumer that accesses media.objectURL mints a fresh URL from the same Blob, so live re-renders just work.
  • If the underlying handle errored before settling, the promise rejects and useMediaURL stays at undefined. Inspect media.error to surface the failure.

Pair with useAudio / useImages / useVideo / useFiles to bridge SDK media handles into React DOM nodes without manual URL.createObjectURL bookkeeping.

Copy
useMediaURL(media: MediaBase | undefined): string | undefined

Parameters

NameTypeDescription
media*MediaBase | undefined
View source on GitHub