Skip to main content
Important

This feature is currently in Early Availability (EA) status. For more information, see our product lifecycle phases.

Add Static Assets

If you are developing an extension that requires static assets such as images, videos, or CSS files, you can easily add them to your extension and access them in your code. In order to add static assets to your extension, you need to follow these steps:

Step 1: Add Your Static Assets

Add your static assets to the static/assets folder of your extension. You can add any type of static asset, such as images, videos, or CSS files.

.
└── src
└── static
└── assets
├── myimage.png
├── styles.css
└── video.mp4

Step 2: Access Your Static Assets

You can access your static assets in your extension's code by using the window.get_extension_assets function. This function takes the filename of the asset you want to fetch as a parameter.

For example, if you have an image named myimage.png in your static/assets folder, you can fetch it in your code like this:

const App = () => {
const imageUrl = window.get_extension_assets('myimage.png');
return (
<div>
<img alt="test img" src={imageUrl}/>
</div>
);
};

This will return the URL of the image, which you can use to display the image in your extension.

And that's it! By following these simple steps, you can easily add static assets to your extension and access them in your code.

Was this page helpful?