There is no such thing as “import Figma into code” because Figma doesn’t provide any code for components (the code doesn’t exist in the first place so there is nothing to import). You always need to process them in some way to turn them into actually usable React code. And that’s exactly what third-party tools do.
Thanks for the quick reply. I did read that you can use these imports in React. import { fetchFile, fetchNodes } from 'figma-api'; import { generateComponent } from 'react-figma'. I just wondered if anyone had this working?
import is simply a keyword in JS to use a library in the current file. So the first statement allows you to use figma-api library, the second one is for react-figma library. Importing a library is very different from importing a component.
figma-api library is just a simplifying wrapper for making API calls to Figma REST API. It doesn’t provide any extra functionality for working with React. Clarified this just in case. Also it seems like you are using it not as documented so it might not work depending on your setup.
Not sure which react-figma package you are using, but the only one I could find is not a code generator and it doesn’t have a function you are trying to import from it. It does exactly the opposite: generates Figma nodes from React code.