Skip to main content
Solved

Is there a way to open an URL via plugin command?

  • August 26, 2021
  • 7 replies
  • 2391 views

Andrey_Shakhmin

I’m looking for a way to open an URL in a new tab to show some docs related to a certain command. Is there a way to perform such action via plugin’s backend script without spawning a hidden UI with iframe and all?

Best answer by Gleb

You can submit requests right on the forum in the #plugin-api:feedback category.

However, if you need the UI to just perform this action, it should be pretty easy, not much messing around:

const url = 'http://example.com'
const openLinkUIString = `<script>window.open('${url}','_blank');</script>`

figma.showUI(openLinkUIString, { visible: false })

setTimeout(figma.closePlugin, 1000)
View original

7 replies

Gleb
  • Power Member
  • 4707 replies
  • August 26, 2021

No, it can only be done with a UI.


Andrey_Shakhmin

Hey @Gleb !

I’m new to this figma plugins thing, I bet you know the place where to submit feature requests related to plugins and the dev program. It’s such a pity there is no way to perform such a useful action without messing with the UI part of the thing. 🙃


Gleb
  • Power Member
  • 4707 replies
  • Answer
  • August 26, 2021

You can submit requests right on the forum in the #plugin-api:feedback category.

However, if you need the UI to just perform this action, it should be pretty easy, not much messing around:

const url = 'http://example.com'
const openLinkUIString = `<script>window.open('${url}','_blank');</script>`

figma.showUI(openLinkUIString, { visible: false })

setTimeout(figma.closePlugin, 1000)

Andrey_Shakhmin

Wow! Works like a charm! 👏 👏 👏

I thought it requires a lot more labor in order to do it. Thank you very much for the code snippet! 🙏


Govind_Chandran

Hey @Gleb
I was trying to open a url in the figma plugin itself using showUI and iframe but it shows 403 error. The link is opening in my browser window properly

figma.showUI( <iframe width="100%" height="100%" src="https://api.x.xxx.com/v1/oauth/google"></iframe>,
{ width: 750, height: 500, title:“Login to DevBud”}
);

Its for a google authentication process. That link is not the exact url but looks like it.
It feels like either CORS error or whitelisted domain error. Can you tell what it is and a workaround for it


Gleb
  • Power Member
  • 4707 replies
  • February 28, 2023

Search for oauth in the API docs or forum, this isn’t as simple as that.


Govind_Chandran

What could be the issue, I have been going through the doc… no luck


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings