Prepare a Remotion project for remocn
Project root: $ARGUMENTS (the current folder when empty)
shadcn init refuses a Remotion project ("could not detect a supported framework"), and Remotion's
bundler doesn't read tsconfig paths. So a fresh project needs three small edits before the first
component lands. Make them yourself with your file tools, in this order. Skip each one the project
already has.
0. Check the project
Read package.json in the project root.
- No
package.json: stop and say so. - No
remotionindependenciesordevDependencies: it isn't a Remotion project. Stop and say so. Theremocn-videoskill creates one withnpx create-video@latest --yes --blank <folder>.
In a project the user already had, list the files from the steps below that you will touch and ask before editing them.
1. components.json
-
Missing: create it with exactly this content:
{ "$schema": "https://ui.shadcn.com/schema.json", "style": "new-york", "rsc": false, "tsx": true, "tailwind": { "config": "", "css": "", "baseColor": "neutral", "cssVariables": false }, "aliases": { "components": "@/components", "utils": "@/lib/utils", "ui": "@/components/ui", "lib": "@/lib", "hooks": "@/hooks" }, "registries": { "@remocn": "https://remocn.dev/r/{name}.json" } } -
Present, no
registries["@remocn"]: add"@remocn": "https://remocn.dev/r/{name}.json"toregistries, creating the object if needed. Leave every other field as it is. -
Already has
@remocn: leave it.
2. The @/* path in tsconfig.json
remocn components import each other through @/, so TypeScript has to resolve it. tsconfig.json
may hold comments and trailing commas: edit it in place and keep them.
Work out the alias folder, the folder @/ points at, relative to the project root. You need it
in step 3.
compilerOptions.paths["@/*"]exists: leave the file. The alias folder is its first entry without the trailing/*(./src/*→src), resolved againstcompilerOptions.baseUrlwhen one is set, else against the folder oftsconfig.json.- The file has
extendsand nopathsof its own: a localpathswould replace the inherited map, not merge with it. Open the config it extends (one level, relative paths only). If that one has@/*, leave both files and take the alias folder from there, resolved against the parent's folder. If it doesn't, don't edit: tell the user to add"@/*": ["./src/*"]where their paths are defined, and usesrcas the alias folder. - Otherwise: add
"@/*": ["./src/*"]tocompilerOptions.paths, creatingpathsif needed and keeping existing entries. With abaseUrlother than., write the path tosrcrelative to thebaseUrlinstead. The alias folder issrc. - No
tsconfig.json: don't create one. The alias folder issrc.
3. The @ alias in remotion.config.ts
The bundler needs the same alias. Look for remotion.config.ts, then remotion.config.js, in the
project root. If the file already contains withRemocnAlias, leave it.
The alias target is path.join(process.cwd(), "<alias folder>"), or process.cwd() when the alias
folder is the project root itself.
- No config file: create
remotion.config.tswith the imports and the block below. remotion.config.tsexists: addimport path from "node:path";andimport { Config } from "@remotion/cli/config";at the top unless they're already imported, then append the block at the end of the file.remotion.config.jsexists: append the same block without the type annotations (const withRemocnAlias = (config) => ({ ... })andconfig.resolve?.alias ?? {}), and the same two imports if missing.
// remocn components import each other through the "@/" alias in components.json.
// Bundlers don't read tsconfig paths, so the alias is resolved here as well.
// Both overrides are deliberate: the Remotion CLI applies overrideBundlerConfig
// with webpack and rspack alike, while Remocn Studio's preview reads only
// overrideWebpackConfig. Both run from the project root, which process.cwd()
// points at.
const withRemocnAlias = <C extends { resolve?: object }>(config: C): C => ({
...config,
resolve: {
...config.resolve,
alias: {
...((config.resolve as { alias?: object } | undefined)?.alias ?? {}),
"@": path.join(process.cwd(), "src"),
},
},
});
// overrideBundlerConfig only exists in newer Remotion 4 releases.
if (typeof Config.overrideBundlerConfig === "function") {
Config.overrideBundlerConfig(withRemocnAlias);
}
Config.overrideWebpackConfig(withRemocnAlias);
Replace path.join(process.cwd(), "src") with the alias target from above when they differ.
4. Report
Tell the user, in a few lines, what each step did: created, changed or left as it was, plus anything
they have to add by hand. Then npx shadcn@latest add @remocn/<name> works in the project.