Skip to content

🎥 Make videos programmatically with React

Merge remote-tracking branch 'origin/main' into codex/element-library-terminology

JonnyBurger293371d36ab2
diff --cc packages/docs/docs/studio-protocol/static-file-ref.mdx
index 0000000000,b5caa7109c..1455a488a0
mode 000000,100644..100644
--- a/packages/docs/docs/studio-protocol/static-file-ref.mdx
+++ b/packages/docs/docs/studio-protocol/static-file-ref.mdx
@@@ -1,0 -1,80 +1,80 @@@
+ ---
+ image: /generated/articles-docs-studio-protocol-static-file-ref.png
+ title: 'staticFileRef()'
+ crumb: '@remotion/studio-protocol'
+ ---
+
+ # staticFileRef()<AvailableFrom v="4.0.528" />
+
+ Reference an Element asset in [`initialProps`](/docs/studio-protocol/create-element-payload#initialprops). When the Element is installed, Studio downloads the asset into the user's project's `public/` directory and generates a [`staticFile()`](/docs/staticfile) expression on the component invocation. The Element source is not rewritten.
+
+ ## Example
+
+ Accept the asset URL as a component prop:
+
+ ```tsx twoslash title="MyElement.tsx"
+ import {Img} from 'remotion';
+
+ export const MyElement = ({logoSrc}: {logoSrc: string}) => (
+ <Img name="Logo" src={logoSrc} />
+ );
+ ```
+
+ Declare the asset and reference it in the installation props:
+
+ ```ts twoslash title="element-payload.ts"
+ import {createElementPayload, staticFileRef} from '@remotion/studio-protocol';
+
+ const sourceCode = `export const MyElement = ({logoSrc}: {logoSrc: string}) => <img src={logoSrc} />;`;
+ // ---cut---
+ const logo = {
+ path: 'my-element/logo.png',
+ type: 'url',
+ url: 'https://cdn.example.com/logo.png',
+ } as const;
+
+ const payload = createElementPayload({
+ displayName: 'My Element',
+ slug: 'my-element',
+ sourceCode,
+ dependencies: [],
+ dimensions: {width: 900, height: 260},
+ durationInFrames: 90,
+ assets: [logo],
+ initialProps: {
+ logoSrc: staticFileRef(logo.path),
+ },
+ });
+ ```
+
+ Studio saves the asset to `public/my-element/logo.png` and inserts:
+
+ ```tsx title="Generated component invocation"
+ <MyElement logoSrc={staticFile('my-element/logo.png')} />
+ ```
+
+ This works in both installation modes. In `'wrapped'` mode, Studio places this invocation inside a generated `<Sequence>`.
+
+ For the website preview, pass the hosted URL as the Player's `inputProps`, for example `inputProps={{logoSrc: logo.url}}`. Do not pass the reference object to the preview component: it is installation metadata, not a URL.
+
+ ## Arguments
+
+ ### path
+
+ A public-relative path that exactly matches an entry in the payload's [`assets`](/docs/studio-protocol/create-element-payload#assets). The path may come from a variable. Undeclared paths and malformed references are rejected before asset downloads.
+
+ ## Return value
+
+ A JSON-serializable `StaticFileRef` object for use in `initialProps`. References may also appear inside nested objects and arrays. Pass the returned value unchanged; do not construct or depend on its internal representation.
+
+ For assets that should remain remote after installation, pass a URL string instead.
+
+ ## Compatibility
+
+ <CompatibilityTable chrome firefox safari nodejs="" bun="" serverlessFunctions="" clientSideRendering={false} serverSideRendering={false} player={false} studio={false} hideServers />
+
+ ## See also
+
+ - [`createElementPayload()`](/docs/studio-protocol/create-element-payload)
-- [Integrating a component library with Studio](/docs/studio-protocol/component-library-integration)
++- [Integrating an Element Library with Studio](/docs/studio-protocol/component-library-integration)
+ - [`staticFile()`](/docs/staticfile)
diff --cc packages/docs/src/components/Elements/element-definitions.ts
index 4a348119cd,2d166dbf74..c9241dc25d
--- a/packages/docs/src/components/Elements/element-definitions.ts
+++ b/packages/docs/src/components/Elements/element-definitions.ts
@@@ -94,7 -106,25 +106,25 @@@ export type ElementDefinition =
readonly width: number;
};
+ const youtubeSubscribeNudgeAssets = {
+ click: {
+ path: 'elements/youtube-subscribe-nudge/mouse-click.wav',
+ type: 'url',
+ url: mouseClick,
+ },
+ ding: {
+ path: 'elements/youtube-subscribe-nudge/ding.wav',
+ type: 'url',
+ url: ding,
+ },
+ avatar: {
+ path: 'elements/youtube-subscribe-nudge/remotion-logo.png',
+ type: 'url',
+ url: 'https://remotion.media/elements/social-endcard-remotion-logo.png',
+ },
+ } as const satisfies Record<string, ElementAsset>;
+
-// Array order defines the order of categories and cards in the Element library.
+// Array order defines the order of categories and cards in the Element Library.
const elementImplementations = [
{
slug: 'audio/oscilloscope',