Skip to content

🎥 Make videos programmatically with React

finish + docs

Jonny Burger328e6e3abc4c
diff --git a/packages/docs/docs/studio/TableOfContents.tsx b/packages/docs/docs/studio/TableOfContents.tsx
index 7676659d2c..aeb50798e5 100644
--- a/packages/docs/docs/studio/TableOfContents.tsx
+++ b/packages/docs/docs/studio/TableOfContents.tsx
@@ -12,6 +12,10 @@ export const TableOfContents: React.FC = () => {
Get a list of files in the <code>public</code> folder
</div>
</TOCItem>
+ <TOCItem link="/docs/studio/watch-public-folder">
+ <strong>{"watchPublicFolder()"}</strong>
+ <div>Listen to changes in the public folder</div>
+ </TOCItem>
<TOCItem link="/docs/studio/watch-static-file">
<strong>{"watchStaticFile()"}</strong>
<div>Listen to changes of a static file</div>
diff --git a/packages/docs/docs/studio/update-default-props.mdx b/packages/docs/docs/studio/update-default-props.mdx
index a01e91dfe8..0db7d3781a 100644
--- a/packages/docs/docs/studio/update-default-props.mdx
+++ b/packages/docs/docs/studio/update-default-props.mdx
@@ -1,4 +1,5 @@
---
+image: /generated/articles-docs-studio-update-default-props.png
title: updateDefaultProps()
crumb: "@remotion/studio"
---
diff --git a/packages/docs/docs/studio/watch-public-folder.mdx b/packages/docs/docs/studio/watch-public-folder.mdx
new file mode 100644
index 0000000000..ecb4c6a45d
--- /dev/null
+++ b/packages/docs/docs/studio/watch-public-folder.mdx
@@ -0,0 +1,42 @@
+---
+image: /generated/articles-docs-studio-watch-public-folder.png
+title: watchPublicFolder()
+crumb: "@remotion/studio"
+---
+
+# watchPublicFolder()<AvailableFrom v="4.0.154"/>
+
+Watches for changes in the [public directory](/docs/terminology/public-dir) and calls a callback function when a file is added, removed or modified.
+
+:::note
+This feature is only available within the Remotion Studio environment. In the Player, events will never fire.
+:::
+
+## Example
+
+```tsx twoslash title="example.tsx"
+import { StaticFile, watchPublicFolder } from "@remotion/studio";
+
+// Watch for changes in a specific static file
+const { cancel } = watchPublicFolder((newFiles: StaticFile[]) => {
+ console.log("The public folder now contains:", newFiles);
+});
+
+// To stop watching for changes, call the cancel function
+cancel();
+```
+
+## Arguments
+
+Takes one argument and returns a function that can be used to `cancel` the event listener.
+
+### `callback`
+
+A callback function that will be called when the directory is modified. As an argument, an array of [`StaticFile`](/docs/getstaticfiles#api)'s is passed.
+
+## See also
+
+- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/studio/src/api/watch-public-folder.ts)
+- [`watchStaticFile()`](/docs/studio/watch-static-file)
+- [`staticFile()`](/docs/staticfile)
+- [`getStaticFiles()`](/docs/studio/get-static-files)
diff --git a/packages/docs/docs/studio/watch-static-file.mdx b/packages/docs/docs/studio/watch-static-file.mdx
index 7d5ca8e573..c411646d9d 100644
--- a/packages/docs/docs/studio/watch-static-file.mdx
+++ b/packages/docs/docs/studio/watch-static-file.mdx
@@ -53,5 +53,6 @@ A callback function that will be called when the file is modified. As an argumen
## See also
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/studio/src/api/watch-static-file.ts)
+- [`watchPublicFolder()`](/docs/studio/watch-public-folder)
- [`staticFile()`](/docs/staticfile)
- [`getStaticFiles()`](/docs/studio/get-static-files)
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index 2574b2eb23..cebb30859f 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -430,6 +430,7 @@ module.exports = {
},
items: [
"studio/get-static-files",
+ "studio/watch-public-folder",
"studio/watch-static-file",
"studio/write-static-file",
"studio/save-default-props",
diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.ts
index c2af5ca715..302d6f0e5d 100644
--- a/packages/docs/src/data/articles.ts
+++ b/packages/docs/src/data/articles.ts
@@ -2864,6 +2864,20 @@ export const articles = [
compId: "articles-docs-studio-studio",
crumb: "Timeline basics",
},
+ {
+ id: "studio/update-default-props",
+ title: "updateDefaultProps()",
+ relativePath: "docs/studio/update-default-props.mdx",
+ compId: "articles-docs-studio-update-default-props",
+ crumb: "@remotion/studio",
+ },
+ {
+ id: "studio/watch-public-folder",
+ title: "watchPublicFolder()",
+ relativePath: "docs/studio/watch-public-folder.mdx",
+ compId: "articles-docs-studio-watch-public-folder",
+ crumb: "@remotion/studio",
+ },
{
id: "studio/watch-static-file",
title: "watchStaticFile()",
diff --git a/packages/docs/static/generated/articles-docs-studio-update-default-props.png b/packages/docs/static/generated/articles-docs-studio-update-default-props.png
new file mode 100644
index 0000000000..ed3a36c55b
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-studio-update-default-props.png differ
diff --git a/packages/docs/static/generated/articles-docs-studio-watch-public-folder.png b/packages/docs/static/generated/articles-docs-studio-watch-public-folder.png
new file mode 100644
index 0000000000..ea0b3582f7
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-studio-watch-public-folder.png differ
diff --git a/packages/studio/src/api/watch-public-folder.ts b/packages/studio/src/api/watch-public-folder.ts
index 5863d75b74..2c61b51308 100644
--- a/packages/studio/src/api/watch-public-folder.ts
+++ b/packages/studio/src/api/watch-public-folder.ts
@@ -5,10 +5,6 @@ type WatcherCallback = (newFiles: StaticFile[]) => void;
export const WATCH_REMOTION_STATIC_FILES = 'remotion_staticFilesChanged';
-export type WatchRemotionStaticFilesPayload = {
- files: StaticFile[];
-};
-
/**
* @description Watch for changes in the public folder.
* @param {Function} callback - A callback function to be called when the file changes.
diff --git a/packages/studio/src/index.ts b/packages/studio/src/index.ts
index d306e3fda7..cd789ccf90 100644
--- a/packages/studio/src/index.ts
+++ b/packages/studio/src/index.ts
@@ -2,5 +2,6 @@ export {StaticFile, getStaticFiles} from './api/get-static-files';
export {UpdateDefaultPropsFunction} from './api/helpers/calc-new-props';
export {saveDefaultProps} from './api/save-default-props';
export {updateDefaultProps} from './api/update-default-props';
+export {watchPublicFolder} from './api/watch-public-folder';
export {watchStaticFile} from './api/watch-static-file';
export {writeStaticFile} from './api/write-static-file';