Skip to main content

deleteStaticFile()v4.0.154

Deletes a file from the public directory.
This API is useful for building interactive experiences in the Remotion Studio.

Examples

Delete 'video.webm'
tsx
import React, { useCallback } from "react";
import { deleteStaticFile } from "@remotion/studio";
 
export const DeleteStaticFileComp: React.FC = () => {
const deleteFile = useCallback(async () => {
const { existed } = await deleteStaticFile("video.webm");
 
console.log(`Deleted file (${existed ? "existed" : "did not exist"})`);
}, []);
 
return <button onClick={deleteFile}>Delete</button>;
};
Delete 'video.webm'
tsx
import React, { useCallback } from "react";
import { deleteStaticFile } from "@remotion/studio";
 
export const DeleteStaticFileComp: React.FC = () => {
const deleteFile = useCallback(async () => {
const { existed } = await deleteStaticFile("video.webm");
 
console.log(`Deleted file (${existed ? "existed" : "did not exist"})`);
}, []);
 
return <button onClick={deleteFile}>Delete</button>;
};

Rules

This API can only be used while in the Remotion Studio.


The file path must be relative to the public directory .


It's not allowed to delete a file outside the public directory .
4
To delete a file in a subfolder, use forward slashes / even on Windows.
5
You can, but don't have to wrap the file path in a staticFile() function.

See also