Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I encode a string in Typescript when implementing Figma plugin

I'm implementing a Figma plugin, and I need to encode a line of text in base 64. I've found that I can implement that function with

I've tried

Buffer.from('STRING').toString('base64')

but Buffer is not recognized in @figma/plugin-typings

This project is not a Node.js project but a Figma plugin, so I wonder if there's another way to implement this or a package that is available for Typescript.

like image 669
Roger Lo Avatar asked Mar 08 '26 22:03

Roger Lo


1 Answers

Use base64encode

You would have to convert the string to Uint8Array first though.

like image 196
Alan Ho Avatar answered Mar 10 '26 10:03

Alan Ho