Back to Remotion

deleteStaticFile()

packages/docs/docs/studio/delete-static-file.mdx

4.0.4701.6 KB
Original Source

deleteStaticFile()<AvailableFrom v="4.0.154"/>

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

Examples

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

<Step>1</Step> This API can only be used while in the Remotion Studio.

<Step>2</Step> The file path must be relative to the <a href="/docs/terminology/public-dir"> <code>public</code> directory </a>.

<Step>3</Step> It's not allowed to delete a file outside the <a href="/docs/terminology/public-dir"> <code>public</code> directory </a>.

<Step>4</Step> To delete a file in a subfolder, use forward slashes <code> / </code> even on Windows. <Step>5</Step> You can, but don't have to wrap the file path in a <a href="/docs/staticfile"> <code>staticFile()</code> </a> function.

See also