packages/docs/docs/watch-static-file.mdx
:::note
This API is being moved to the @remotion/studio package. Prefer importing the API from @remotion/studio instead of remotion.
:::
Watches for changes in a specific static file and invokes a callback function when the file changes, enabling dynamic updates in your Remotion projects.
:::warning This feature is only available within the Remotion Studio environment. In the Player, events will never fire. :::
import { StaticFile, watchStaticFile } from "remotion";
// Watch for changes in a specific static file
const { cancel } = watchStaticFile(
"your-static-file.jpg",
(newData: StaticFile | null) => {
if (newData) {
console.log(`File ${newData.name} has been added or modified.`);
} else {
console.log("File has been deleted.");
}
},
);
// To stop watching for changes, call the cancel function
cancel();
Takes two arguments and returns a function that can be used to cancel the event listener.
filenameA name of the file in /public folder to watch for changes.
callbackA callback function that will be called when the file is modified. As an argument, a StaticFile or null is passed.
<CompatibilityTable chrome firefox safari nodejs={""} bun={""} serverlessFunctions="" clientSideRendering={false} serverSideRendering={false} player={false} studio hideBrowsers hideServers />