Skip to content

🎥 Make videos programmatically with React

add documentation with advice for how to encode filenames for staticFile

Jonny Burger56f3f0b0aff7
diff --git a/packages/docs/docs/staticfile.md b/packages/docs/docs/staticfile.md
index 3f2079286a..73a251e95e 100644
--- a/packages/docs/docs/staticfile.md
+++ b/packages/docs/docs/staticfile.md
@@ -55,12 +55,18 @@ You can now load the asset via:
## Why can't I just pass a string?
-If you are a Create React App or Next.JS user, you might be used to just to be able to reference the asset from a string: `<img src="/my-image.png"/>`. Remotion is different in that you need to use the `staticFile()` API because:
+If you are a Create React App or Next.JS user, you might be used to just to be able to reference the asset from a string: `<img src="/my-image.png"/>`. Remotion chooses to be different in that you need to use the `staticFile()` API because:
- It prevents breaking when deploying your site into a subdirectory of a domain: `https://example.com/my-folder/my-logo.png`
- It avoids conflicts with composition names which might share the same name (for example `http://localhost:3000/conflicting-name` while running the preview)
- It allows us to make paths framework-agnostic, so your code can work across Remotion, Create React App, Next.JS and potentially other frameworks.
+## URL encoding
+
+If you import a file via this API, a URL is generated. Therefore you have to make sure to encode non-URL-safe characters in your filename.
+If on your filesystem, file is named `Video #1.mp4`, in your code you should import it using `staticFile("Video%20%201.mp4")`.
+You can achieve this via the browser-built-in `encodeURIComponent()` function: `staticFile(encodeURIComponent("Video #1.mp4"))`.
+
## See also
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/core/src/static-file.ts)