Way to dynamically size plugin window based on browser window?

Is there a way to dynamically size the plugin window based on browser window?
Looking for a height and width to plug into

figma.showUI(___html___, {height, width})

Methods tried:

  • document.documentElement.clientWidth (document is not defined)
  • parent.document.body.clientWidth (parent is not defined)
  • window.outerWidth (window is not defined)
  • figma.viewport dimensions do not correspond to browser window dimensions.

You tried these methods on the plugins backend side, but you need to do it on the UI side.

Hey, thanks for looking. Can you please elaborate? When I try to access the figma object from within the React app, I get this error:
ReferenceError: figma is not defined

None of the methods you mentioned except the last one needs figma.

You can’t access figma object in the UI. UI is for all the browser APIs, backend is for interacting with figma. See this post on how to communicate between the two environments: Creating a User Interface | Plugin API