Skip to content

🎥 Make videos programmatically with React

Copy nextjs-tailwind template

ASchwad5f76b4bdee5e
diff --git a/bun.lock b/bun.lock
index ddc3dc495f..d22f86da5a 100644
--- a/bun.lock
+++ b/bun.lock
@@ -1,6 +1,5 @@
{
"lockfileVersion": 1,
- "configVersion": 0,
"workspaces": {
"": {
"name": "remotion-monorepo",
@@ -95,6 +94,10 @@
"@remotion/bundler": "workspace:*",
},
},
+ "packages/bugs": {
+ "name": "bugs",
+ "version": "4.0.379",
+ },
"packages/bundler": {
"name": "@remotion/bundler",
"version": "4.0.379",
@@ -195,6 +198,14 @@
"eslint": "catalog:",
},
},
+ "packages/cloudrun/container": {
+ "name": "cloud-run-render",
+ "version": "4.0.379",
+ "dependencies": {
+ "@google-cloud/functions-framework": "^3.1.3",
+ "@puppeteer/browsers": "^2.3.0",
+ },
+ },
"packages/compositor": {
"name": "@remotion/compositor",
"version": "4.0.379",
@@ -4293,6 +4304,8 @@
"buffer-from": ["[email protected]", "", {}, "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ=="],
+ "bugs": ["bugs@workspace:packages/bugs"],
+
"bun": ["[email protected]", "", { "optionalDependencies": { "@oven/bun-darwin-aarch64": "1.3.3", "@oven/bun-darwin-x64": "1.3.3", "@oven/bun-darwin-x64-baseline": "1.3.3", "@oven/bun-linux-aarch64": "1.3.3", "@oven/bun-linux-aarch64-musl": "1.3.3", "@oven/bun-linux-x64": "1.3.3", "@oven/bun-linux-x64-baseline": "1.3.3", "@oven/bun-linux-x64-musl": "1.3.3", "@oven/bun-linux-x64-musl-baseline": "1.3.3", "@oven/bun-windows-x64": "1.3.3", "@oven/bun-windows-x64-baseline": "1.3.3" }, "os": [ "linux", "win32", "darwin", ], "cpu": [ "x64", "arm64", ], "bin": { "bun": "bin/bun.exe", "bunx": "bin/bunx.exe" } }, "sha512-2hJ4ocTZ634/Ptph4lysvO+LbbRZq8fzRvMwX0/CqaLBxrF2UB5D1LdMB8qGcdtCer4/VR9Bx5ORub0yn+yzmw=="],
"bun-plugin-tailwind": ["[email protected]", "", { "peerDependencies": { "bun": ">=1.0.0" } }, "sha512-41jNC1tZRSK3s1o7pTNrLuQG8kL/0vR/JgiTmZAJ1eHwe0w5j6HFPKeqEk0WAD13jfrUC7+ULuewFBBCoADPpg=="],
@@ -4393,6 +4406,8 @@
"clone-deep": ["[email protected]", "", { "dependencies": { "is-plain-object": "2.0.4", "kind-of": "6.0.3", "shallow-clone": "3.0.1" } }, "sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ=="],
+ "cloud-run-render": ["cloud-run-render@workspace:packages/cloudrun/container"],
+
"cloudevents": ["[email protected]", "", { "dependencies": { "ajv": "8.11.0", "ajv-formats": "2.1.1", "json-bigint": "1.0.0", "process": "0.11.10", "util": "0.12.5", "uuid": "8.3.2" } }, "sha512-93KKRR61D2NNE+2lg2HmLbl17beVTKpf1UYd/8BcXpuiDxbU2fb8gAfriSmVGmj1xX/Oh2t5Fh/xGOWFdu6F4A=="],
"clsx": ["[email protected]", "", {}, "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA=="],
diff --git a/packages/template-code-generation/.env.example b/packages/template-code-generation/.env.example
new file mode 100644
index 0000000000..51ee435c39
--- /dev/null
+++ b/packages/template-code-generation/.env.example
@@ -0,0 +1,4 @@
+REMOTION_AWS_ACCESS_KEY_ID=""
+REMOTION_AWS_SECRET_ACCESS_KEY=""
+
+OPENAI_API_KEY=""
\ No newline at end of file
diff --git a/packages/template-code-generation/.gitignore b/packages/template-code-generation/.gitignore
new file mode 100644
index 0000000000..1efb618ffa
--- /dev/null
+++ b/packages/template-code-generation/.gitignore
@@ -0,0 +1,39 @@
+# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
+
+# dependencies
+/node_modules
+/.pnp
+.pnp.js
+
+# testing
+/coverage
+
+# next.js
+/.next/
+/out/
+
+# production
+/build
+
+# misc
+.DS_Store
+*.pem
+
+# debug
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+.pnpm-debug.log*
+
+# local env files
+.env*.local
+
+# vercel
+.vercel
+
+# typescript
+*.tsbuildinfo
+next-env.d.ts
+out/
+.env
+build
\ No newline at end of file
diff --git a/packages/template-code-generation/.npmrc b/packages/template-code-generation/.npmrc
new file mode 100644
index 0000000000..3e775efb0f
--- /dev/null
+++ b/packages/template-code-generation/.npmrc
@@ -0,0 +1 @@
+auto-install-peers=true
diff --git a/packages/template-code-generation/.prettierrc b/packages/template-code-generation/.prettierrc
new file mode 100644
index 0000000000..37d5071748
--- /dev/null
+++ b/packages/template-code-generation/.prettierrc
@@ -0,0 +1,5 @@
+{
+ "useTabs": false,
+ "bracketSpacing": true,
+ "tabWidth": 2
+}
diff --git a/packages/template-code-generation/README.md b/packages/template-code-generation/README.md
new file mode 100644
index 0000000000..f3ce3caad1
--- /dev/null
+++ b/packages/template-code-generation/README.md
@@ -0,0 +1,88 @@
+<img src="https://github.com/remotion-dev/template-next/assets/1629785/9092db5f-7c0c-4d38-97c4-5f5a61f5cc098" />
+<br/>
+<br/>
+
+This is a Next.js template for building programmatic video apps, with [`@remotion/player`](https://remotion.dev/player) and [`@remotion/lambda`](https://remotion.dev/lambda) built in.
+
+This template uses the Next.js App directory, with TailwindCSS. There is a [Non-TailwindCSS version](https://github.com/remotion-dev/template-next-app-dir), and a [Pages directory version](https://github.com/remotion-dev/template-next-pages-dir) of this template available.
+
+<img src="https://github.com/remotion-dev/template-next/assets/1629785/c9c2e5ca-2637-4ec8-8e40-a8feb5740d88" />
+
+## Getting Started
+
+[Use this template](https://github.com/new?template_name=template-next-app-dir-tailwind&template_owner=remotion-dev) to clone it into your GitHub account. Run
+
+```
+npm i
+```
+
+afterwards. Alternatively, use this command to scaffold a project:
+
+```
+npx create-video@latest --next-tailwind
+```
+
+## Commands
+
+Start the Next.js dev server:
+
+```
+npm run dev
+```
+
+Open the Remotion Studio:
+
+```
+npx remotion studio
+```
+
+Render a video locally:
+
+```
+npx remotion render
+```
+
+Upgrade Remotion:
+
+```
+npx remotion upgrade
+```
+
+The following script will set up your Remotion Bundle and Lambda function on AWS:
+
+```
+node deploy.mjs
+```
+
+You should run this script after:
+
+- changing the video template
+- changing `config.mjs`
+- upgrading Remotion to a newer version
+
+## Set up rendering on AWS Lambda
+
+This template supports rendering the videos via [Remotion Lambda](https://remotion.dev/lambda).
+
+1. Copy the `.env.example` file to `.env` and fill in the values.
+ Complete the [Lambda setup guide](https://www.remotion.dev/docs/lambda/setup) to get your AWS credentials.
+
+1. Edit the `config.mjs` file to your desired Lambda settings.
+
+1. Run `node deploy.mjs` to deploy your Lambda function and Remotion Bundle.
+
+## Docs
+
+Get started with Remotion by reading the [fundamentals page](https://www.remotion.dev/docs/the-fundamentals).
+
+## Help
+
+We provide help on our [Discord server](https://remotion.dev/discord).
+
+## Issues
+
+Found an issue with Remotion? [File an issue here](https://remotion.dev/issue).
+
+## License
+
+Note that for some entities a company license is needed. [Read the terms here](https://github.com/remotion-dev/remotion/blob/main/LICENSE.md).
diff --git a/packages/template-code-generation/config.mjs b/packages/template-code-generation/config.mjs
new file mode 100644
index 0000000000..b18ed95152
--- /dev/null
+++ b/packages/template-code-generation/config.mjs
@@ -0,0 +1,10 @@
+/**
+ * Use autocomplete to get a list of available regions.
+ * @type {import('@remotion/lambda').AwsRegion}
+ */
+export const REGION = "us-east-1";
+
+export const SITE_NAME = "my-next-app";
+export const RAM = 3009;
+export const DISK = 10240;
+export const TIMEOUT = 240;
diff --git a/packages/template-code-generation/deploy.mjs b/packages/template-code-generation/deploy.mjs
new file mode 100644
index 0000000000..2dcc0bd8fe
--- /dev/null
+++ b/packages/template-code-generation/deploy.mjs
@@ -0,0 +1,79 @@
+import {
+ deployFunction,
+ deploySite,
+ getOrCreateBucket,
+} from "@remotion/lambda";
+import dotenv from "dotenv";
+import path from "path";
+import { DISK, RAM, REGION, SITE_NAME, TIMEOUT } from "./config.mjs";
+import { webpackOverride } from "./src/remotion/webpack-override.mjs";
+
+console.log("Selected region:", REGION);
+dotenv.config();
+
+if (!process.env.AWS_ACCESS_KEY_ID && !process.env.REMOTION_AWS_ACCESS_KEY_ID) {
+ console.log(
+ 'The environment variable "REMOTION_AWS_ACCESS_KEY_ID" is not set.',
+ );
+ console.log("Lambda renders were not set up.");
+ console.log(
+ "Complete the Lambda setup: at https://www.remotion.dev/docs/lambda/setup",
+ );
+ process.exit(0);
+}
+if (
+ !process.env.AWS_SECRET_ACCESS_KEY &&
+ !process.env.REMOTION_AWS_SECRET_ACCESS_KEY
+) {
+ console.log(
+ 'The environment variable "REMOTION_REMOTION_AWS_SECRET_ACCESS_KEY" is not set.',
+ );
+ console.log("Lambda renders were not set up.");
+ console.log(
+ "Complete the Lambda setup: at https://www.remotion.dev/docs/lambda/setup",
+ );
+ process.exit(0);
+}
+
+process.stdout.write("Deploying Lambda function... ");
+
+const { functionName, alreadyExisted: functionAlreadyExisted } =
+ await deployFunction({
+ createCloudWatchLogGroup: true,
+ memorySizeInMb: RAM,
+ region: REGION,
+ timeoutInSeconds: TIMEOUT,
+ diskSizeInMb: DISK,
+ });
+console.log(
+ functionName,
+ functionAlreadyExisted ? "(already existed)" : "(created)",
+);
+
+process.stdout.write("Ensuring bucket... ");
+const { bucketName, alreadyExisted: bucketAlreadyExisted } =
+ await getOrCreateBucket({
+ region: REGION,
+ });
+console.log(
+ bucketName,
+ bucketAlreadyExisted ? "(already existed)" : "(created)",
+);
+
+process.stdout.write("Deploying site... ");
+const { siteName } = await deploySite({
+ bucketName,
+ entryPoint: path.join(process.cwd(), "src", "remotion", "index.ts"),
+ siteName: SITE_NAME,
+ region: REGION,
+ options: { webpackOverride },
+});
+
+console.log(siteName);
+
+console.log();
+console.log("You now have everything you need to render videos!");
+console.log("Re-run this command when:");
+console.log(" 1) you changed the video template");
+console.log(" 2) you changed config.mjs");
+console.log(" 3) you upgraded Remotion to a newer version");
diff --git a/packages/template-code-generation/eslint.config.mjs b/packages/template-code-generation/eslint.config.mjs
new file mode 100644
index 0000000000..b37f42b202
--- /dev/null
+++ b/packages/template-code-generation/eslint.config.mjs
@@ -0,0 +1,53 @@
+import js from "@eslint/js";
+import nextPlugin from "@next/eslint-plugin-next";
+import remotion from "@remotion/eslint-plugin";
+import tseslint from "typescript-eslint";
+
+// Build Next.js recommended rules and an "off" map for overrides
+const nextRecommended = nextPlugin.configs.recommended ?? { rules: {} };
+const nextRecommendedRules = nextRecommended.rules ?? {};
+const offNextRules = Object.fromEntries(
+ Object.keys(nextRecommendedRules).map((k) => [k, "off"]),
+);
+
+export default [
+ // Global ignores
+ {
+ ignores: [
+ "node_modules/**",
+ ".next/**",
+ "out/**",
+ "build/**",
+ "next-env.d.ts",
+ "next.config.js",
+ "deploy.mjs",
+ ],
+ },
+ // Base JS recommended
+ js.configs.recommended,
+ // TypeScript recommended (non type-checked for speed/simplicity)
+ ...tseslint.configs.recommended,
+ // Next.js recommended rules applied to app code
+ {
+ files: ["**/*.{js,jsx,ts,tsx}"],
+ plugins: { "@next/next": nextPlugin },
+ rules: {
+ ...nextRecommendedRules,
+ },
+ },
+ // Remotion rules applied only to remotion files
+ {
+ files: ["src/remotion/**"],
+ ...remotion.flatPlugin,
+ rules: {
+ ...remotion.flatPlugin.rules,
+ },
+ },
+ // Disable all Next.js rules within remotion files
+ {
+ files: ["src/remotion/**"],
+ rules: {
+ ...offNextRules,
+ },
+ },
+];
diff --git a/packages/template-code-generation/next.config.js b/packages/template-code-generation/next.config.js
new file mode 100644
index 0000000000..91ef62f0db
--- /dev/null
+++ b/packages/template-code-generation/next.config.js
@@ -0,0 +1,6 @@
+/** @type {import('next').NextConfig} */
+const nextConfig = {
+ reactStrictMode: true,
+};
+
+module.exports = nextConfig;
diff --git a/packages/template-code-generation/package.json b/packages/template-code-generation/package.json
new file mode 100644
index 0000000000..624663185b
--- /dev/null
+++ b/packages/template-code-generation/package.json
@@ -0,0 +1,52 @@
+{
+ "name": "template-code-generation",
+ "version": "0.1.0",
+ "scripts": {
+ "dev": "next dev",
+ "build": "next build",
+ "start": "next start",
+ "lint": "eslint .",
+ "remotion": "remotion studio",
+ "render": "remotion render",
+ "deploy": "node deploy.mjs"
+ },
+ "dependencies": {
+ "@remotion/bundler": "workspace:*",
+ "@remotion/cli": "workspace:*",
+ "@remotion/google-fonts": "workspace:*",
+ "@remotion/lambda": "workspace:*",
+ "@remotion/paths": "workspace:*",
+ "@remotion/player": "workspace:*",
+ "@remotion/shapes": "workspace:*",
+ "@remotion/tailwind-v4": "workspace:*",
+ "clsx": "2.1.1",
+ "next": "16.0.0",
+ "react": "19.0.0",
+ "react-dom": "19.0.0",
+ "remotion": "workspace:*",
+ "tailwind-merge": "3.0.1",
+ "zod": "3.22.3"
+ },
+ "devDependencies": {
+ "@tailwindcss/postcss": "4.1.1",
+ "@remotion/eslint-plugin": "workspace:*",
+ "@eslint/eslintrc": "3.1.0",
+ "@eslint/js": "9.38.0",
+ "@types/node": "20.12.14",
+ "@types/react": "19.0.0",
+ "@types/react-dom": "19.0.0",
+ "@types/web": "0.0.166",
+ "autoprefixer": "10.4.20",
+ "dotenv": "16.0.3",
+ "eslint": "9.19.0",
+ "@next/eslint-plugin-next": "15.1.6",
+ "eslint-config-next": "15.1.6",
+ "@typescript-eslint/eslint-plugin": "8.46.0",
+ "@typescript-eslint/parser": "8.46.0",
+ "postcss": "8.4.47",
+ "prettier": "3.6.0",
+ "tailwindcss": "4.0.3",
+ "typescript": "5.8.2",
+ "typescript-eslint": "8.46.0"
+ }
+}
diff --git a/packages/template-code-generation/postcss.config.mjs b/packages/template-code-generation/postcss.config.mjs
new file mode 100644
index 0000000000..7059fe95ad
--- /dev/null
+++ b/packages/template-code-generation/postcss.config.mjs
@@ -0,0 +1,6 @@
+const config = {
+ plugins: {
+ "@tailwindcss/postcss": {},
+ },
+};
+export default config;
diff --git a/packages/template-code-generation/remotion.config.ts b/packages/template-code-generation/remotion.config.ts
new file mode 100644
index 0000000000..cbf7520d9b
--- /dev/null
+++ b/packages/template-code-generation/remotion.config.ts
@@ -0,0 +1,11 @@
+// See all configuration options: https://remotion.dev/docs/config
+// Each option also is available as a CLI flag: https://remotion.dev/docs/cli
+
+// Note: When using the Node.JS APIs, the config file doesn't apply. Instead, pass options directly to the APIs
+
+import { Config } from "@remotion/cli/config";
+import { webpackOverride } from "./src/remotion/webpack-override.mjs";
+
+Config.setVideoImageFormat("jpeg");
+
+Config.overrideWebpackConfig(webpackOverride);
diff --git a/packages/template-code-generation/src/app/api/lambda/progress/route.ts b/packages/template-code-generation/src/app/api/lambda/progress/route.ts
new file mode 100644
index 0000000000..7f6fbcfcba
--- /dev/null
+++ b/packages/template-code-generation/src/app/api/lambda/progress/route.ts
@@ -0,0 +1,44 @@
+import {
+ speculateFunctionName,
+ AwsRegion,
+ getRenderProgress,
+} from "@remotion/lambda/client";
+import { DISK, RAM, REGION, TIMEOUT } from "../../../../../config.mjs";
+import { ProgressResponse, ProgressRequest } from "../../../../../types/schema";
+import { executeApi } from "../../../../helpers/api-response";
+
+export const POST = executeApi<ProgressResponse, typeof ProgressRequest>(
+ ProgressRequest,
+ async (req, body) => {
+ const renderProgress = await getRenderProgress({
+ bucketName: body.bucketName,
+ functionName: speculateFunctionName({
+ diskSizeInMb: DISK,
+ memorySizeInMb: RAM,
+ timeoutInSeconds: TIMEOUT,
+ }),
+ region: REGION as AwsRegion,
+ renderId: body.id,
+ });
+
+ if (renderProgress.fatalErrorEncountered) {
+ return {
+ type: "error",
+ message: renderProgress.errors[0].message,
+ };
+ }
+
+ if (renderProgress.done) {
+ return {
+ type: "done",
+ url: renderProgress.outputFile as string,
+ size: renderProgress.outputSizeInBytes as number,
+ };
+ }
+
+ return {
+ type: "progress",
+ progress: Math.max(0.03, renderProgress.overallProgress),
+ };
+ },
+);
diff --git a/packages/template-code-generation/src/app/api/lambda/render/route.ts b/packages/template-code-generation/src/app/api/lambda/render/route.ts
new file mode 100644
index 0000000000..822349c0b4
--- /dev/null
+++ b/packages/template-code-generation/src/app/api/lambda/render/route.ts
@@ -0,0 +1,56 @@
+import { AwsRegion, RenderMediaOnLambdaOutput } from "@remotion/lambda/client";
+import {
+ renderMediaOnLambda,
+ speculateFunctionName,
+} from "@remotion/lambda/client";
+import {
+ DISK,
+ RAM,
+ REGION,
+ SITE_NAME,
+ TIMEOUT,
+} from "../../../../../config.mjs";
+import { RenderRequest } from "../../../../../types/schema";
+import { executeApi } from "../../../../helpers/api-response";
+
+export const POST = executeApi<RenderMediaOnLambdaOutput, typeof RenderRequest>(
+ RenderRequest,
+ async (req, body) => {
+ if (
+ !process.env.AWS_ACCESS_KEY_ID &&
+ !process.env.REMOTION_AWS_ACCESS_KEY_ID
+ ) {
+ throw new TypeError(
+ "Set up Remotion Lambda to render videos. See the README.md for how to do so.",
+ );
+ }
+ if (
+ !process.env.AWS_SECRET_ACCESS_KEY &&
+ !process.env.REMOTION_AWS_SECRET_ACCESS_KEY
+ ) {
+ throw new TypeError(
+ "The environment variable REMOTION_AWS_SECRET_ACCESS_KEY is missing. Add it to your .env file.",
+ );
+ }
+
+ const result = await renderMediaOnLambda({
+ codec: "h264",
+ functionName: speculateFunctionName({
+ diskSizeInMb: DISK,
+ memorySizeInMb: RAM,
+ timeoutInSeconds: TIMEOUT,
+ }),
+ region: REGION as AwsRegion,
+ serveUrl: SITE_NAME,
+ composition: body.id,
+ inputProps: body.inputProps,
+ framesPerLambda: 10,
+ downloadBehavior: {
+ type: "download",
+ fileName: "video.mp4",
+ },
+ });
+
+ return result;
+ },
+);
diff --git a/packages/template-code-generation/src/app/favicon.ico b/packages/template-code-generation/src/app/favicon.ico
new file mode 100644
index 0000000000..718d6fea48
Binary files /dev/null and b/packages/template-code-generation/src/app/favicon.ico differ
diff --git a/packages/template-code-generation/src/app/layout.tsx b/packages/template-code-generation/src/app/layout.tsx
new file mode 100644
index 0000000000..e19d2dc5cb
--- /dev/null
+++ b/packages/template-code-generation/src/app/layout.tsx
@@ -0,0 +1,25 @@
+import "../../styles/global.css";
+import { Metadata, Viewport } from "next";
+
+export const metadata: Metadata = {
+ title: "Remotion and Next.js",
+ description: "Remotion and Next.js",
+};
+
+export const viewport: Viewport = {
+ width: "device-width",
+ initialScale: 1,
+ maximumScale: 1,
+};
+
+export default function RootLayout({
+ children,
+}: {
+ children: React.ReactNode;
+}) {
+ return (
+ <html lang="en">
+ <body className="bg-background">{children}</body>
+ </html>
+ );
+}
diff --git a/packages/template-code-generation/src/app/page.tsx b/packages/template-code-generation/src/app/page.tsx
new file mode 100644
index 0000000000..1f92cb246a
--- /dev/null
+++ b/packages/template-code-generation/src/app/page.tsx
@@ -0,0 +1,65 @@
+"use client";
+
+import { Player } from "@remotion/player";
+import type { NextPage } from "next";
+import { useMemo, useState } from "react";
+import { z } from "zod";
+import {
+ defaultMyCompProps,
+ CompositionProps,
+ DURATION_IN_FRAMES,
+ VIDEO_FPS,
+ VIDEO_HEIGHT,
+ VIDEO_WIDTH,
+} from "../../types/constants";
+import { RenderControls } from "../components/RenderControls";
+import { Spacing } from "../components/Spacing";
+import { Tips } from "../components/Tips";
+import { Main } from "../remotion/MyComp/Main";
+
+const Home: NextPage = () => {
+ const [text, setText] = useState<string>(defaultMyCompProps.title);
+
+ const inputProps: z.infer<typeof CompositionProps> = useMemo(() => {
+ return {
+ title: text,
+ };
+ }, [text]);
+
+ return (
+ <div>
+ <div className="max-w-screen-md m-auto mb-5">
+ <div className="overflow-hidden rounded-geist shadow-[0_0_200px_rgba(0,0,0,0.15)] mb-10 mt-16">
+ <Player
+ component={Main}
+ inputProps={inputProps}
+ durationInFrames={DURATION_IN_FRAMES}
+ fps={VIDEO_FPS}
+ compositionHeight={VIDEO_HEIGHT}
+ compositionWidth={VIDEO_WIDTH}
+ style={{
+ // Can't use tailwind class for width since player's default styles take presedence over tailwind's,
+ // but not over inline styles
+ width: "100%",
+ }}
+ controls
+ autoPlay
+ loop
+ />
+ </div>
+ <RenderControls
+ text={text}
+ setText={setText}
+ inputProps={inputProps}
+ ></RenderControls>
+ <Spacing></Spacing>
+ <Spacing></Spacing>
+ <Spacing></Spacing>
+ <Spacing></Spacing>
+ <Tips></Tips>
+ </div>
+ </div>
+ );
+};
+
+export default Home;
diff --git a/packages/template-code-generation/src/components/AlignEnd.tsx b/packages/template-code-generation/src/components/AlignEnd.tsx
new file mode 100644
index 0000000000..7ff7ad53bf
--- /dev/null
+++ b/packages/template-code-generation/src/components/AlignEnd.tsx
@@ -0,0 +1,7 @@
+import React from "react";
+
+export const AlignEnd: React.FC<{
+ children: React.ReactNode;
+}> = ({ children }) => {
+ return <div className="self-end">{children}</div>;
+};
diff --git a/packages/template-code-generation/src/components/Button.tsx b/packages/template-code-generation/src/components/Button.tsx
new file mode 100644
index 0000000000..4f924f335d
--- /dev/null
+++ b/packages/template-code-generation/src/components/Button.tsx
@@ -0,0 +1,39 @@
+import React, { forwardRef } from "react";
+import { Spacing } from "./Spacing";
+import { Spinner } from "./Spinner";
+import { cn } from "../lib/utils";
+
+const ButtonForward: React.ForwardRefRenderFunction<
+ HTMLButtonElement,
+ {
+ onClick?: () => void;
+ disabled?: boolean;
+ children: React.ReactNode;
+ loading?: boolean;
+ secondary?: boolean;
+ }
+> = ({ onClick, disabled, children, loading, secondary }, ref) => {
+ return (
+ <button
+ ref={ref}
+ className={cn(
+ "border-foreground border rounded-geist bg-foreground text-background px-geist-half font-geist h-10 font-medium transition-all duration-150 ease-in-out inline-flex items-center appearance-none text-sm hover:bg-background hover:text-foreground hover:border-focused-border-color disabled:bg-button-disabled-color disabled:text-disabled-text-color disabled:border-unfocused-border-color disabled:cursor-not-allowed",
+ secondary
+ ? "bg-background text-foreground border-unfocused-border-color"
+ : undefined,
+ )}
+ onClick={onClick}
+ disabled={disabled}
+ >
+ {loading && (
+ <>
+ <Spinner size={20}></Spinner>
+ <Spacing></Spacing>
+ </>
+ )}
+ {children}
+ </button>
+ );
+};
+
+export const Button = forwardRef(ButtonForward);
diff --git a/packages/template-code-generation/src/components/Container.tsx b/packages/template-code-generation/src/components/Container.tsx
new file mode 100644
index 0000000000..19cbcb59e5
--- /dev/null
+++ b/packages/template-code-generation/src/components/Container.tsx
@@ -0,0 +1,11 @@
+import React from "react";
+
+export const InputContainer: React.FC<{
+ children: React.ReactNode;
+}> = ({ children }) => {
+ return (
+ <div className="border border-unfocused-border-color p-geist rounded-geist bg-background flex flex-col">
+ {children}
+ </div>
+ );
+};
diff --git a/packages/template-code-generation/src/components/DownloadButton.tsx b/packages/template-code-generation/src/components/DownloadButton.tsx
new file mode 100644
index 0000000000..9ccff26b80
--- /dev/null
+++ b/packages/template-code-generation/src/components/DownloadButton.tsx
@@ -0,0 +1,56 @@
+import React from "react";
+import { State } from "../helpers/use-rendering";
+import { Button } from "./Button";
+import { Spacing } from "./Spacing";
+
+const Megabytes: React.FC<{
+ sizeInBytes: number;
+}> = ({ sizeInBytes }) => {
+ const megabytes = Intl.NumberFormat("en", {
+ notation: "compact",
+ style: "unit",
+ unit: "byte",
+ unitDisplay: "narrow",
+ }).format(sizeInBytes);
+ return <span className="opacity-60">{megabytes}</span>;
+};
+
+export const DownloadButton: React.FC<{
+ state: State;
+ undo: () => void;
+}> = ({ state, undo }) => {
+ if (state.status === "rendering") {
+ return <Button disabled>Download video</Button>;
+ }
+
+ if (state.status !== "done") {
+ throw new Error("Download button should not be rendered when not done");
+ }
+
+ return (
+ <div className="flex">
+ <Button secondary onClick={undo}>
+ <UndoIcon></UndoIcon>
+ </Button>
+ <Spacing></Spacing>
+ <a href={state.url}>
+ <Button>
+ Download video
+ <Spacing></Spacing>
+ <Megabytes sizeInBytes={state.size}></Megabytes>
+ </Button>
+ </a>
+ </div>
+ );
+};
+
+const UndoIcon: React.FC = () => {
+ return (
+ <svg height="1em" viewBox="0 0 512 512">
+ <path
+ fill="var(--foreground)"
+ d="M48.5 224H40c-13.3 0-24-10.7-24-24V72c0-9.7 5.8-18.5 14.8-22.2s19.3-1.7 26.2 5.2L98.6 96.6c87.6-86.5 228.7-86.2 315.8 1c87.5 87.5 87.5 229.3 0 316.8s-229.3 87.5-316.8 0c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0c62.5 62.5 163.8 62.5 226.3 0s62.5-163.8 0-226.3c-62.2-62.2-162.7-62.5-225.3-1L185 183c6.9 6.9 8.9 17.2 5.2 26.2s-12.5 14.8-22.2 14.8H48.5z"
+ />
+ </svg>
+ );
+};
diff --git a/packages/template-code-generation/src/components/Error.tsx b/packages/template-code-generation/src/components/Error.tsx
new file mode 100644
index 0000000000..28020e53c2
--- /dev/null
+++ b/packages/template-code-generation/src/components/Error.tsx
@@ -0,0 +1,25 @@
+import React from "react";
+
+export const ErrorComp: React.FC<{
+ message: string;
+}> = ({ message }) => {
+ return (
+ <div className="text-geist-error font-geist py-geist-half">
+ <svg
+ fill="none"
+ shapeRendering="geometricPrecision"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="2"
+ viewBox="0 0 24 24"
+ className="h-5 align-text-bottom mr-1.5 inline"
+ >
+ <circle cx="12" cy="12" r="10" fill="var(--geist-fill)"></circle>
+ <path d="M12 8v4" stroke="currentColor"></path>
+ <path d="M12 16h.01" stroke="currentColor"></path>
+ </svg>
+ <strong>Error:</strong> {message}
+ </div>
+ );
+};
diff --git a/packages/template-code-generation/src/components/Input.tsx b/packages/template-code-generation/src/components/Input.tsx
new file mode 100644
index 0000000000..d6dcc0434d
--- /dev/null
+++ b/packages/template-code-generation/src/components/Input.tsx
@@ -0,0 +1,24 @@
+import React, { useCallback } from "react";
+
+export const Input: React.FC<{
+ text: string;
+ setText: React.Dispatch<React.SetStateAction<string>>;
+ disabled?: boolean;
+}> = ({ text, setText, disabled }) => {
+ const onChange: React.ChangeEventHandler<HTMLInputElement> = useCallback(
+ (e) => {
+ setText(e.currentTarget.value);
+ },
+ [setText],
+ );
+
+ return (
+ <input
+ className="leading-[1.7] block w-full rounded-geist bg-background p-geist-half text-foreground text-sm border border-unfocused-border-color transition-colors duration-150 ease-in-out focus:border-focused-border-color outline-none"
+ disabled={disabled}
+ name="title"
+ value={text}
+ onChange={onChange}
+ />
+ );
+};
diff --git a/packages/template-code-generation/src/components/ProgressBar.tsx b/packages/template-code-generation/src/components/ProgressBar.tsx
new file mode 100644
index 0000000000..a4c5886df7
--- /dev/null
+++ b/packages/template-code-generation/src/components/ProgressBar.tsx
@@ -0,0 +1,22 @@
+import React, { useMemo } from "react";
+
+export const ProgressBar: React.FC<{
+ progress: number;
+}> = ({ progress }) => {
+ const fill: React.CSSProperties = useMemo(() => {
+ return {
+ width: `${progress * 100}%`,
+ };
+ }, [progress]);
+
+ return (
+ <div>
+ <div className="w-full h-2.5 rounded-md appearance-none bg-unfocused-border-color mt-2.5 mb-6">
+ <div
+ className="bg-foreground h-2.5 rounded-md transition-all ease-in-out duration-100"
+ style={fill}
+ ></div>
+ </div>
+ </div>
+ );
+};
diff --git a/packages/template-code-generation/src/components/RenderControls.tsx b/packages/template-code-generation/src/components/RenderControls.tsx
new file mode 100644
index 0000000000..3711310095
--- /dev/null
+++ b/packages/template-code-generation/src/components/RenderControls.tsx
@@ -0,0 +1,59 @@
+import { z } from "zod";
+import { AlignEnd } from "./AlignEnd";
+import { Button } from "./Button";
+import { InputContainer } from "./Container";
+import { DownloadButton } from "./DownloadButton";
+import { ErrorComp } from "./Error";
+import { Input } from "./Input";
+import { ProgressBar } from "./ProgressBar";
+import { Spacing } from "./Spacing";
+import { COMP_NAME, CompositionProps } from "../../types/constants";
+import { useRendering } from "../helpers/use-rendering";
+
+export const RenderControls: React.FC<{
+ text: string;
+ setText: React.Dispatch<React.SetStateAction<string>>;
+ inputProps: z.infer<typeof CompositionProps>;
+}> = ({ text, setText, inputProps }) => {
+ const { renderMedia, state, undo } = useRendering(COMP_NAME, inputProps);
+
+ return (
+ <InputContainer>
+ {state.status === "init" ||
+ state.status === "invoking" ||
+ state.status === "error" ? (
+ <>
+ <Input
+ disabled={state.status === "invoking"}
+ setText={setText}
+ text={text}
+ ></Input>
+ <Spacing></Spacing>
+ <AlignEnd>
+ <Button
+ disabled={state.status === "invoking"}
+ loading={state.status === "invoking"}
+ onClick={renderMedia}
+ >
+ Render video
+ </Button>
+ </AlignEnd>
+ {state.status === "error" ? (
+ <ErrorComp message={state.error.message}></ErrorComp>
+ ) : null}
+ </>
+ ) : null}
+ {state.status === "rendering" || state.status === "done" ? (
+ <>
+ <ProgressBar
+ progress={state.status === "rendering" ? state.progress : 1}
+ />
+ <Spacing></Spacing>
+ <AlignEnd>
+ <DownloadButton undo={undo} state={state}></DownloadButton>
+ </AlignEnd>
+ </>
+ ) : null}
+ </InputContainer>
+ );
+};
diff --git a/packages/template-code-generation/src/components/Spacing.tsx b/packages/template-code-generation/src/components/Spacing.tsx
new file mode 100644
index 0000000000..c901cfdadb
--- /dev/null
+++ b/packages/template-code-generation/src/components/Spacing.tsx
@@ -0,0 +1,5 @@
+import React from "react";
+
+export const Spacing: React.FC = () => {
+ return <div className="w-geist-quarter h-geist-quarter" />;
+};
diff --git a/packages/template-code-generation/src/components/Spinner.tsx b/packages/template-code-generation/src/components/Spinner.tsx
new file mode 100644
index 0000000000..405f2260c1
--- /dev/null
+++ b/packages/template-code-generation/src/components/Spinner.tsx
@@ -0,0 +1,46 @@
+import React, { useMemo } from "react";
+import { makeRect } from "@remotion/shapes";
+import { translatePath } from "@remotion/paths";
+
+const viewBox = 100;
+const lines = 12;
+const width = viewBox * 0.08;
+
+const { path } = makeRect({
+ height: viewBox * 0.24,
+ width,
+ cornerRadius: width / 2,
+});
+
+const translated = translatePath(path, viewBox / 2 - width / 2, viewBox * 0.03);
+
+export const Spinner: React.FC<{
+ size: number;
+}> = ({ size }) => {
+ const style = useMemo(() => {
+ return {
+ width: size,
+ height: size,
+ };
+ }, [size]);
+
+ return (
+ <svg style={style} viewBox={`0 0 ${viewBox} ${viewBox}`}>
+ {new Array(lines).fill(true).map((_, index) => {
+ return (
+ <path
+ className="animate-spinner"
+ style={{
+ rotate: `${(index * Math.PI * 2) / lines}rad`,
+ transformOrigin: "center center",
+ animationDelay: `${index * 0.1 - lines * 0.1}s`,
+ }}
+ key={index}
+ d={translated}
+ fill="var(--foreground)"
+ ></path>
+ );
+ })}
+ </svg>
+ );
+};
diff --git a/packages/template-code-generation/src/components/Tips.tsx b/packages/template-code-generation/src/components/Tips.tsx
new file mode 100644
index 0000000000..4e0d16cf4e
--- /dev/null
+++ b/packages/template-code-generation/src/components/Tips.tsx
@@ -0,0 +1,53 @@
+import React from "react";
+
+const Tip: React.FC<{
+ title: React.ReactNode;
+ description: React.ReactNode;
+ href: string;
+}> = ({ title, description, href }) => {
+ return (
+ <a href={href} target="_blank" rel="noreferrer" className="flex-1">
+ <div className="transition-transform duration-200 ease-in-out p-2.5 group hover:-translate-y-0.5">
+ <div className="flex flex-row items-center justify-start">
+ <h4 className="my-3 font-bold text-foreground">{title}</h4>
+ <div className="flex-1"></div>
+ <svg
+ className="opacity-0 transition-opacity duration-200 ease-in-out group-hover:opacity-100"
+ height="1em"
+ viewBox="0 0 448 512"
+ >
+ <path
+ fill="var(--foreground)"
+ d="M438.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L338.8 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l306.7 0L233.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160z"
+ />
+ </svg>
+ </div>
+ <p className="text-sm leading-normal text-subtitle mb-6">
+ {description}
+ </p>
+ </div>
+ </a>
+ );
+};
+
+export const Tips: React.FC = () => {
+ return (
+ <div className="flex flex-col md:flex-row font-geist">
+ <Tip
+ href="https://www.remotion.dev/docs/the-fundamentals"
+ title="Learn Remotion"
+ description="Learn how to customize this video written in React."
+ ></Tip>
+ <Tip
+ href="https://github.com/remotion-dev/template-next-app-dir"
+ title="See source"
+ description="Visit the GitHub repository for this app."
+ ></Tip>
+ <Tip
+ href="https://remotion.dev/discord"
+ title="Join the community"
+ description="Chat with others builders on Discord."
+ ></Tip>
+ </div>
+ );
+};
diff --git a/packages/template-code-generation/src/helpers/api-response.ts b/packages/template-code-generation/src/helpers/api-response.ts
new file mode 100644
index 0000000000..d4da4ce786
--- /dev/null
+++ b/packages/template-code-generation/src/helpers/api-response.ts
@@ -0,0 +1,36 @@
+import { NextResponse } from "next/server";
+import { z, ZodType } from "zod";
+
+export type ApiResponse<Res> =
+ | {
+ type: "error";
+ message: string;
+ }
+ | {
+ type: "success";
+ data: Res;
+ };
+
+export const executeApi =
+ <Res, Req extends ZodType>(
+ schema: Req,
+ handler: (req: Request, body: z.infer<Req>) => Promise<Res>,
+ ) =>
+ async (req: Request) => {
+ try {
+ const payload = await req.json();
+ const parsed = schema.parse(payload);
+ const data = await handler(req, parsed);
+ return NextResponse.json({
+ type: "success",
+ data: data,
+ });
+ } catch (err) {
+ return NextResponse.json(
+ { type: "error", message: (err as Error).message },
+ {
+ status: 500,
+ },
+ );
+ }
+ };
diff --git a/packages/template-code-generation/src/helpers/use-rendering.ts b/packages/template-code-generation/src/helpers/use-rendering.ts
new file mode 100644
index 0000000000..ff7c29efdb
--- /dev/null
+++ b/packages/template-code-generation/src/helpers/use-rendering.ts
@@ -0,0 +1,116 @@
+import { z } from "zod";
+import { useCallback, useMemo, useState } from "react";
+import { getProgress, renderVideo } from "../lambda/api";
+import { CompositionProps } from "../../types/constants";
+
+export type State =
+ | {
+ status: "init";
+ }
+ | {
+ status: "invoking";
+ }
+ | {
+ renderId: string;
+ bucketName: string;
+ progress: number;
+ status: "rendering";
+ }
+ | {
+ renderId: string | null;
+ status: "error";
+ error: Error;
+ }
+ | {
+ url: string;
+ size: number;
+ status: "done";
+ };
+
+const wait = async (milliSeconds: number) => {
+ await new Promise<void>((resolve) => {
+ setTimeout(() => {
+ resolve();
+ }, milliSeconds);
+ });
+};
+
+export const useRendering = (
+ id: string,
+ inputProps: z.infer<typeof CompositionProps>,
+) => {
+ const [state, setState] = useState<State>({
+ status: "init",
+ });
+
+ const renderMedia = useCallback(async () => {
+ setState({
+ status: "invoking",
+ });
+ try {
+ const { renderId, bucketName } = await renderVideo({ id, inputProps });
+ setState({
+ status: "rendering",
+ progress: 0,
+ renderId: renderId,
+ bucketName: bucketName,
+ });
+
+ let pending = true;
+
+ while (pending) {
+ const result = await getProgress({
+ id: renderId,
+ bucketName: bucketName,
+ });
+ switch (result.type) {
+ case "error": {
+ setState({
+ status: "error",
+ renderId: renderId,
+ error: new Error(result.message),
+ });
+ pending = false;
+ break;
+ }
+ case "done": {
+ setState({
+ size: result.size,
+ url: result.url,
+ status: "done",
+ });
+ pending = false;
+ break;
+ }
+ case "progress": {
+ setState({
+ status: "rendering",
+ bucketName: bucketName,
+ progress: result.progress,
+ renderId: renderId,
+ });
+ await wait(1000);
+ }
+ }
+ }
+ } catch (err) {
+ setState({
+ status: "error",
+ error: err as Error,
+ renderId: null,
+ });
+ }
+ }, [id, inputProps]);
+
+ const undo = useCallback(() => {
+ setState({ status: "init" });
+ }, []);
+
+ return useMemo(() => {
+ return {
+ renderMedia,
+ state,
+ undo,
+ };
+ }, [renderMedia, state, undo]);
+};
diff --git a/packages/template-code-generation/src/lambda/api.ts b/packages/template-code-generation/src/lambda/api.ts
new file mode 100644
index 0000000000..f1182d9577
--- /dev/null
+++ b/packages/template-code-generation/src/lambda/api.ts
@@ -0,0 +1,58 @@
+import { z } from "zod";
+import type { RenderMediaOnLambdaOutput } from "@remotion/lambda/client";
+import {
+ ProgressRequest,
+ ProgressResponse,
+ RenderRequest,
+} from "../../types/schema";
+import { CompositionProps } from "../../types/constants";
+import { ApiResponse } from "../helpers/api-response";
+
+const makeRequest = async <Res>(
+ endpoint: string,
+ body: unknown,
+): Promise<Res> => {
+ const result = await fetch(endpoint, {
+ method: "post",
+ body: JSON.stringify(body),
+ headers: {
+ "content-type": "application/json",
+ },
+ });
+ const json = (await result.json()) as ApiResponse<Res>;
+ if (json.type === "error") {
+ throw new Error(json.message);
+ }
+
+ return json.data;
+};
+
+export const renderVideo = async ({
+ id,
+ inputProps,
+}: {
+ id: string;
+ inputProps: z.infer<typeof CompositionProps>;
+}) => {
+ const body: z.infer<typeof RenderRequest> = {
+ id,
+ inputProps,
+ };
+
+ return makeRequest<RenderMediaOnLambdaOutput>("/api/lambda/render", body);
+};
+
+export const getProgress = async ({
+ id,
+ bucketName,
+}: {
+ id: string;
+ bucketName: string;
+}) => {
+ const body: z.infer<typeof ProgressRequest> = {
+ id,
+ bucketName,
+ };
+
+ return makeRequest<ProgressResponse>("/api/lambda/progress", body);
+};
diff --git a/packages/template-code-generation/src/lib/utils.ts b/packages/template-code-generation/src/lib/utils.ts
new file mode 100644
index 0000000000..a5ef193506
--- /dev/null
+++ b/packages/template-code-generation/src/lib/utils.ts
@@ -0,0 +1,6 @@
+import { clsx, type ClassValue } from "clsx";
+import { twMerge } from "tailwind-merge";
+
+export function cn(...inputs: ClassValue[]) {
+ return twMerge(clsx(inputs));
+}
diff --git a/packages/template-code-generation/src/remotion/MyComp/Main.tsx b/packages/template-code-generation/src/remotion/MyComp/Main.tsx
new file mode 100644
index 0000000000..cf23037a59
--- /dev/null
+++ b/packages/template-code-generation/src/remotion/MyComp/Main.tsx
@@ -0,0 +1,58 @@
+import { z } from "zod";
+import {
+ AbsoluteFill,
+ Sequence,
+ spring,
+ useCurrentFrame,
+ useVideoConfig,
+} from "remotion";
+import { CompositionProps } from "../../../types/constants";
+import { NextLogo } from "./NextLogo";
+import { loadFont, fontFamily } from "@remotion/google-fonts/Inter";
+import { Rings } from "./Rings";
+import { TextFade } from "./TextFade";
+
+loadFont("normal", {
+ subsets: ["latin"],
+ weights: ["400", "700"],
+});
+export const Main = ({ title }: z.infer<typeof CompositionProps>) => {
+ const frame = useCurrentFrame();
+ const { fps } = useVideoConfig();
+
+ const transitionStart = 2 * fps;
+ const transitionDuration = 1 * fps;
+
+ const logoOut = spring({
+ fps,
+ frame,
+ config: {
+ damping: 200,
+ },
+ durationInFrames: transitionDuration,
+ delay: transitionStart,
+ });
+
+ return (
+ <AbsoluteFill className="bg-white">
+ <Sequence durationInFrames={transitionStart + transitionDuration}>
+ <Rings outProgress={logoOut}></Rings>
+ <AbsoluteFill className="justify-center items-center">
+ <NextLogo outProgress={logoOut}></NextLogo>
+ </AbsoluteFill>
+ </Sequence>
+ <Sequence from={transitionStart + transitionDuration / 2}>
+ <TextFade>
+ <h1
+ className="text-[70px] font-bold"
+ style={{
+ fontFamily,
+ }}
+ >
+ {title}
+ </h1>
+ </TextFade>
+ </Sequence>
+ </AbsoluteFill>
+ );
+};
diff --git a/packages/template-code-generation/src/remotion/MyComp/NextLogo.tsx b/packages/template-code-generation/src/remotion/MyComp/NextLogo.tsx
new file mode 100644
index 0000000000..b7f87f6bf2
--- /dev/null
+++ b/packages/template-code-generation/src/remotion/MyComp/NextLogo.tsx
@@ -0,0 +1,122 @@
+import { evolvePath } from "@remotion/paths";
+import React, { useMemo } from "react";
+import { interpolate, spring, useCurrentFrame, useVideoConfig } from "remotion";
+
+const nStroke =
+ "M149.508 157.52L69.142 54H54V125.97H66.1136V69.3836L139.999 164.845C143.333 162.614 146.509 160.165 149.508 157.52Z";
+
+export const NextLogo: React.FC<{
+ outProgress: number;
+}> = ({ outProgress }) => {
+ const { fps } = useVideoConfig();
+ const frame = useCurrentFrame();
+
+ const evolve1 = spring({
+ fps,
+ frame,
+ config: {
+ damping: 200,
+ },
+ });
+ const evolve2 = spring({
+ fps,
+ frame: frame - 15,
+ config: {
+ damping: 200,
+ },
+ });
+ const evolve3 = spring({
+ fps,
+ frame: frame - 30,
+ config: {
+ damping: 200,
+ mass: 3,
+ },
+ durationInFrames: 30,
+ });
+
+ const style: React.CSSProperties = useMemo(() => {
+ return {
+ height: 140,
+ borderRadius: 70,
+ scale: String(1 - outProgress),
+ };
+ }, [outProgress]);
+
+ const firstPath = `M 60.0568 54 v 71.97`;
+ const secondPath = `M 63.47956 56.17496 L 144.7535 161.1825`;
+ const thirdPath = `M 121 54 L 121 126`;
+
+ const evolution1 = evolvePath(evolve1, firstPath);
+ const evolution2 = evolvePath(evolve2, secondPath);
+ const evolution3 = evolvePath(
+ interpolate(evolve3, [0, 1], [0, 0.7]),
+ thirdPath,
+ );
+
+ return (
+ <svg style={style} fill="none" viewBox="0 0 180 180">
+ <mask
+ height="180"
+ id="mask"
+ className="[mask-type:alpha]"
+ width="180"
+ x="0"
+ y="0"
+ >
+ <circle cx="90" cy="90" fill="black" r="90"></circle>
+ </mask>
+ <mask id="n-mask" className="[mask-type:alpha]">
+ <path d={nStroke} fill="black"></path>
+ </mask>
+ <g mask="url(#mask)">
+ <circle cx="90" cy="90" fill="black" r="90"></circle>
+ <g stroke="url(#gradient0)" mask="url(#n-mask)">
+ <path
+ strokeWidth="12.1136"
+ d={firstPath}
+ strokeDasharray={evolution1.strokeDasharray}
+ strokeDashoffset={evolution1.strokeDashoffset}
+ ></path>
+ <path
+ strokeWidth={12.1136}
+ d={secondPath}
+ strokeDasharray={evolution2.strokeDasharray}
+ strokeDashoffset={evolution2.strokeDashoffset}
+ ></path>
+ </g>
+ <path
+ stroke="url(#gradient1)"
+ d={thirdPath}
+ strokeDasharray={evolution3.strokeDasharray}
+ strokeDashoffset={evolution3.strokeDashoffset}
+ strokeWidth="12"
+ ></path>
+ </g>
+ <defs>
+ <linearGradient
+ gradientUnits="userSpaceOnUse"
+ id="gradient0"
+ x1="109"
+ x2="144.5"
+ y1="116.5"
+ y2="160.5"
+ >
+ <stop stopColor="white"></stop>
+ <stop offset="1" stopColor="white" stopOpacity="0"></stop>
+ </linearGradient>
+ <linearGradient
+ gradientUnits="userSpaceOnUse"
+ id="gradient1"
+ x1="121"
+ x2="120.799"
+ y1="54"
+ y2="106.875"
+ >
+ <stop stopColor="white"></stop>
+ <stop offset="1" stopColor="white" stopOpacity="0"></stop>
+ </linearGradient>
+ </defs>
+ </svg>
+ );
+};
diff --git a/packages/template-code-generation/src/remotion/MyComp/Rings.tsx b/packages/template-code-generation/src/remotion/MyComp/Rings.tsx
new file mode 100644
index 0000000000..8e27bae856
--- /dev/null
+++ b/packages/template-code-generation/src/remotion/MyComp/Rings.tsx
@@ -0,0 +1,56 @@
+import React from "react";
+import { AbsoluteFill, interpolateColors, useVideoConfig } from "remotion";
+
+const RadialGradient: React.FC<{
+ radius: number;
+ color: string;
+}> = ({ radius, color }) => {
+ const height = radius * 2;
+ const width = radius * 2;
+
+ return (
+ <AbsoluteFill
+ style={{
+ justifyContent: "center",
+ alignItems: "center",
+ }}
+ >
+ <div
+ style={{
+ height,
+ width,
+ backgroundColor: color,
+ }}
+ className="rounded-[50%] absolute shadow-[0px_0px_100px_rgba(0,0,0,0.05)]"
+ ></div>
+ </AbsoluteFill>
+ );
+};
+
+export const Rings: React.FC<{
+ outProgress: number;
+}> = ({ outProgress }) => {
+ const scale = 1 / (1 - outProgress);
+ const { height } = useVideoConfig();
+
+ return (
+ <AbsoluteFill
+ style={{
+ transform: `scale(${scale})`,
+ }}
+ >
+ {new Array(5)
+ .fill(true)
+ .map((_, i) => {
+ return (
+ <RadialGradient
+ key={i}
+ radius={height * 0.3 * i}
+ color={interpolateColors(i, [0, 4], ["#fff", "#fff"])}
+ />
+ );
+ })
+ .reverse()}
+ </AbsoluteFill>
+ );
+};
diff --git a/packages/template-code-generation/src/remotion/MyComp/TextFade.tsx b/packages/template-code-generation/src/remotion/MyComp/TextFade.tsx
new file mode 100644
index 0000000000..1b71930a0b
--- /dev/null
+++ b/packages/template-code-generation/src/remotion/MyComp/TextFade.tsx
@@ -0,0 +1,45 @@
+import React, { useMemo } from "react";
+import {
+ AbsoluteFill,
+ interpolate,
+ spring,
+ useCurrentFrame,
+ useVideoConfig,
+} from "remotion";
+
+export const TextFade: React.FC<{
+ children: React.ReactNode;
+}> = ({ children }) => {
+ const { fps } = useVideoConfig();
+ const frame = useCurrentFrame();
+
+ const progress = spring({
+ fps,
+ frame,
+ config: {
+ damping: 200,
+ },
+ durationInFrames: 80,
+ });
+
+ const rightStop = interpolate(progress, [0, 1], [200, 0]);
+
+ const leftStop = Math.max(0, rightStop - 60);
+
+ const maskImage = `linear-gradient(-45deg, transparent ${leftStop}%, black ${rightStop}%)`;
+
+ const content: React.CSSProperties = useMemo(() => {
+ return {
+ maskImage,
+ WebkitMaskImage: maskImage,
+ };
+ }, [maskImage]);
+
+ return (
+ <AbsoluteFill>
+ <AbsoluteFill className="justify-center items-center">
+ <div style={content}>{children}</div>
+ </AbsoluteFill>
+ </AbsoluteFill>
+ );
+};
diff --git a/packages/template-code-generation/src/remotion/Root.tsx b/packages/template-code-generation/src/remotion/Root.tsx
new file mode 100644
index 0000000000..83276274db
--- /dev/null
+++ b/packages/template-code-generation/src/remotion/Root.tsx
@@ -0,0 +1,38 @@
+import { Composition } from "remotion";
+import { Main } from "./MyComp/Main";
+import {
+ COMP_NAME,
+ defaultMyCompProps,
+ DURATION_IN_FRAMES,
+ VIDEO_FPS,
+ VIDEO_HEIGHT,
+ VIDEO_WIDTH,
+} from "../../types/constants";
+import { NextLogo } from "./MyComp/NextLogo";
+
+export const RemotionRoot: React.FC = () => {
+ return (
+ <>
+ <Composition
+ id={COMP_NAME}
+ component={Main}
+ durationInFrames={DURATION_IN_FRAMES}
+ fps={VIDEO_FPS}
+ width={VIDEO_WIDTH}
+ height={VIDEO_HEIGHT}
+ defaultProps={defaultMyCompProps}
+ />
+ <Composition
+ id="NextLogo"
+ component={NextLogo}
+ durationInFrames={300}
+ fps={30}
+ width={140}
+ height={140}
+ defaultProps={{
+ outProgress: 0,
+ }}
+ />
+ </>
+ );
+};
diff --git a/packages/template-code-generation/src/remotion/index.ts b/packages/template-code-generation/src/remotion/index.ts
new file mode 100644
index 0000000000..23d7a0fb20
--- /dev/null
+++ b/packages/template-code-generation/src/remotion/index.ts
@@ -0,0 +1,5 @@
+import { registerRoot } from "remotion";
+import { RemotionRoot } from "./Root";
+import "../../styles/global.css";
+
+registerRoot(RemotionRoot);
diff --git a/packages/template-code-generation/src/remotion/webpack-override.mjs b/packages/template-code-generation/src/remotion/webpack-override.mjs
new file mode 100644
index 0000000000..2f326a1071
--- /dev/null
+++ b/packages/template-code-generation/src/remotion/webpack-override.mjs
@@ -0,0 +1,8 @@
+import { enableTailwind } from "@remotion/tailwind-v4";
+
+/**
+ * @param {import('webpack').Configuration} currentConfig
+ */
+export const webpackOverride = (currentConfig) => {
+ return enableTailwind(currentConfig);
+};
diff --git a/packages/template-code-generation/styles/global.css b/packages/template-code-generation/styles/global.css
new file mode 100644
index 0000000000..7a4c3bb0ff
--- /dev/null
+++ b/packages/template-code-generation/styles/global.css
@@ -0,0 +1,62 @@
+@import "tailwindcss";
+
+:root {
+ --background: #fff;
+ --foreground: #000;
+ --unfocused-border-color: #eaeaea;
+ --focused-border-color: #666;
+
+ --button-disabled-color: #fafafa;
+ --disabled-text-color: #999;
+
+ --geist-border-radius: 5px;
+ --geist-quarter-pad: 6px;
+ --geist-half-pad: 12px;
+ --geist-pad: 24px;
+ --geist-font: "Inter";
+
+ --geist-error: #e00;
+
+ --subtitle: #666;
+}
+
+@media (prefers-color-scheme: dark) {
+ :root {
+ --background: #000000;
+ --unfocused-border-color: #333;
+ --focused-border-color: #888;
+ --foreground: #fff;
+ --button-disabled-color: #111;
+ --geist-error: red;
+ --subtitle: #8d8d8d;
+ }
+}
+
+@theme {
+ --color-foreground: var(--foreground);
+ --color-background: var(--background);
+ --color-unfocused-border-color: var(--unfocused-border-color);
+ --color-focused-border-color: var(--focused-border-color);
+ --color-button-disabled-color: var(--button-disabled-color);
+ --color-disabled-text-color: var(--disabled-text-color);
+ --color-geist-error: var(--geist-error);
+ --color-subtitle: var(--subtitle);
+ --padding-geist-quarter: var(--geist-quarter-pad);
+ --padding-geist-half: var(--geist-half-pad);
+ --padding-geist: var(--geist-pad);
+ --spacing-geist: var(--geist-pad);
+ --spacing-geist-half: var(--geist-half-pad);
+ --spacing-geist-quarter: var(--geist-quarter-pad);
+ --radius-geist: var(--geist-border-radius);
+ --font-geist: var(--geist-font);
+ --animate-spinner: spinner 1.2s linear infinite;
+
+ @keyframes spinner {
+ 0% {
+ opacity: 1;
+ }
+ 100% {
+ opacity: 0.15;
+ }
+ }
+}
diff --git a/packages/template-code-generation/tsconfig.json b/packages/template-code-generation/tsconfig.json
new file mode 100644
index 0000000000..d317bdd4cc
--- /dev/null
+++ b/packages/template-code-generation/tsconfig.json
@@ -0,0 +1,40 @@
+{
+ "compilerOptions": {
+ "target": "es5",
+ "lib": [
+ "dom",
+ "dom.iterable",
+ "esnext"
+ ],
+ "allowJs": true,
+ "skipLibCheck": true,
+ "strict": true,
+ "forceConsistentCasingInFileNames": true,
+ "noEmit": true,
+ "esModuleInterop": true,
+ "module": "esnext",
+ "moduleResolution": "node",
+ "resolveJsonModule": true,
+ "isolatedModules": true,
+ "jsx": "react-jsx",
+ "noUnusedLocals": true,
+ "plugins": [
+ {
+ "name": "next"
+ }
+ ],
+ "incremental": true
+ },
+ "include": [
+ "next-env.d.ts",
+ "**/*.ts",
+ "**/*.tsx",
+ ".next/types/**/*.ts",
+ "remotion/webpack-override.mjs",
+ ".next/dev/types/**/*.ts"
+ ],
+ "exclude": [
+ "node_modules",
+ "remotion.config.ts"
+ ]
+}
diff --git a/packages/template-code-generation/types/constants.ts b/packages/template-code-generation/types/constants.ts
new file mode 100644
index 0000000000..4767c5e80f
--- /dev/null
+++ b/packages/template-code-generation/types/constants.ts
@@ -0,0 +1,15 @@
+import { z } from "zod";
+export const COMP_NAME = "MyComp";
+
+export const CompositionProps = z.object({
+ title: z.string(),
+});
+
+export const defaultMyCompProps: z.infer<typeof CompositionProps> = {
+ title: "Next.js and Remotion",
+};
+
+export const DURATION_IN_FRAMES = 200;
+export const VIDEO_WIDTH = 1280;
+export const VIDEO_HEIGHT = 720;
+export const VIDEO_FPS = 30;
diff --git a/packages/template-code-generation/types/schema.ts b/packages/template-code-generation/types/schema.ts
new file mode 100644
index 0000000000..da1562f334
--- /dev/null
+++ b/packages/template-code-generation/types/schema.ts
@@ -0,0 +1,27 @@
+import { z } from "zod";
+import { CompositionProps } from "./constants";
+
+export const RenderRequest = z.object({
+ id: z.string(),
+ inputProps: CompositionProps,
+});
+
+export const ProgressRequest = z.object({
+ bucketName: z.string(),
+ id: z.string(),
+});
+
+export type ProgressResponse =
+ | {
+ type: "error";
+ message: string;
+ }
+ | {
+ type: "progress";
+ progress: number;
+ }
+ | {
+ type: "done";
+ url: string;
+ size: number;
+ };
diff --git a/packages/template-code-generation/vercel.json b/packages/template-code-generation/vercel.json
new file mode 100644
index 0000000000..b2129dd8ec
--- /dev/null
+++ b/packages/template-code-generation/vercel.json
@@ -0,0 +1,4 @@
+{
+ "buildCommand": "node deploy.mjs && next build"
+ }
+
\ No newline at end of file