packages/docs/docs/studio/watch-static-file.mdx
Watches for changes in a specific static file and invokes a callback function when the file changes, enabling dynamic updates in your Remotion projects.
:::note
This API is being moved from the <code>remotion</code> package.
Prefer this API over the old one.
:::
:::note This feature is only available within the Remotion Studio environment. In the Player, events will never fire. :::
import { StaticFile, watchStaticFile } from "@remotion/studio";
// 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.