skills/bun-runtime-templating-create/SKILL.md
Create a new Bun project from a React component, a `create-<template>` npm package, a GitHub repo, or a local template
npx skillsauth add jarle/bun-skills Bun bun createInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
<Note> You don't need `bun create` to use Bun. You don't need any configuration at all. This command exists to make getting started a bit quicker and easier. </Note>Create a new Bun project from a React component, a
create-<template>npm package, a GitHub repo, or a local template
Template a new Bun project with bun create. This is a flexible command that can be used to create a new project from a React component, a create-<template> npm package, a GitHub repo, or a local template.
If you're looking to create a brand new empty project, use bun init.
bun create ./MyComponent.tsx turns an existing React component into a complete dev environment with hot reload and production builds in one command.
bun create ./MyComponent.jsx # .tsx also supported
<Frame>
<video style={{ aspectRatio: "2062 / 1344", width: "100%", height: "100%", objectFit: "contain" }} loop autoPlay muted playsInline>
<source src="https://mintcdn.com/bun-1dd33a4e/q61zoUYDXrVRu-tH/images/bun-create-shadcn.mp4?fit=max&auto=format&n=q61zoUYDXrVRu-tH&q=85&s=92fcea5a9d403b155e943508fbb40a21" style={{ width: "100%", height: "100%", objectFit: "contain" }} type="video/mp4" data-path="images/bun-create-shadcn.mp4" />
</video>
</Frame>
<Note>
🚀 **Create React App Successor** — `bun create <component>` provides everything developers loved about Create React App, but with modern tooling, faster builds, and backend support.
</Note>
When you run bun create <component>, Bun:
package.json file with the dependencies and scripts needed to run the component.bun install --only-missing.${component}.html${component}.client.tsx (entry point for the frontend)${component}.css (css file)TailwindCSS is an extremely popular utility-first CSS framework used to style web applications.
When you run bun create <component>, Bun scans your JSX/TSX file for TailwindCSS class names (and any files it imports). If it detects TailwindCSS class names, it will add the following dependencies to your package.json:
{
"dependencies": {
"tailwindcss": "^4",
"bun-plugin-tailwind": "latest"
}
}
We also configure bunfig.toml to use Bun's TailwindCSS plugin with Bun.serve()
[serve.static]
plugins = ["bun-plugin-tailwind"]
And a ${component}.css file with @import "tailwindcss"; at the top:
@import "tailwindcss";
shadcn/ui with Bunshadcn/ui is an extremely popular component library tool for building web applications.
bun create <component> scans for any shadcn/ui components imported from @/components/ui.
If it finds any, it runs:
# Assuming bun detected imports to @/components/ui/accordion and @/components/ui/button
bunx shadcn@canary add accordion button # and any other components
Since shadcn/ui itself uses TailwindCSS, bun create also adds the necessary TailwindCSS dependencies to your package.json and configures bunfig.toml to use Bun's TailwindCSS plugin with Bun.serve() as described above.
Additionally, we setup the following:
tsconfig.json to alias "@/*" to "src/*" or . (depending on if there is a src/ directory)components.json so that shadcn/ui knows its a shadcn/ui projectstyles/globals.css file that configures Tailwind v4 in the way that shadcn/ui expects${component}.build.ts file that builds the component for production with bun-plugin-tailwind configuredbun create ./MyComponent.jsx is one of the easiest ways to run code generated from LLMs like Claude or ChatGPT locally.
npmbun create <template> [<destination>]
Assuming you don't have a local template with the same name, this command will download and execute the create-<template> package from npm. The following two commands will behave identically:
bun create remix
bunx create-remix
Refer to the documentation of the associated create-<template> package for complete documentation and usage instructions.
This will download the contents of the GitHub repo to disk.
bun create <user>/<repo>
bun create github.com/<user>/<repo>
Optionally specify a name for the destination folder. If no destination is specified, the repo name will be used.
bun create <user>/<repo> mydir
bun create github.com/<user>/<repo> mydir
Bun will perform the following steps:
bun install.--no-git flag.start script, if defined.<Note>By default Bun will not overwrite any existing files. Use the --force flag to overwrite existing files.</Note>
Bun's templater can be extended to support custom templates defined on your local file system. These templates should live in one of the following directories:
$HOME/.bun-create/<name>: global templates<project root>/.bun-create/<name>: project-specific templates<Note>You can customize the global template path by setting the BUN_CREATE_DIR environment variable.</Note>
To create a local template, navigate to $HOME/.bun-create and create a new directory with the desired name of your template.
cd $HOME/.bun-create
mkdir foo
cd foo
Then, create a package.json file in that directory with the following contents:
{
"name": "foo"
}
You can run bun create foo elsewhere on your file system to verify that Bun is correctly finding your local template.
You can specify pre- and post-install setup scripts in the "bun-create" section of your local template's package.json.
{
"name": "@bun-examples/simplereact",
"version": "0.0.1",
"main": "index.js",
"dependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"bun-create": {
"preinstall": "echo 'Installing...'", // a single command
"postinstall": ["echo 'Done!'"], // an array of commands
"start": "bun run echo 'Hello world!'"
}
}
The following fields are supported. Each of these can correspond to a string or array of strings. An array of commands will be executed in order.
| Field | Description |
| ------------- | ----------------------------------- |
| postinstall | runs after installing dependencies |
| preinstall | runs before installing dependencies |
After cloning a template, bun create will automatically remove the "bun-create" section from package.json before writing it to the destination folder.
| Flag | Description |
| -------------- | -------------------------------------- |
| --force | Overwrite existing files |
| --no-install | Skip installing node_modules & tasks |
| --no-git | Don't initialize a git repository |
| --open | Start & open in-browser after finish |
| Name | Description |
| ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| GITHUB_API_DOMAIN | If you're using a GitHub enterprise or a proxy, you can customize the GitHub domain Bun pings for downloads |
| GITHUB_TOKEN (or GITHUB_ACCESS_TOKEN) | This lets bun create work with private repositories or if you get rate-limited. GITHUB_TOKEN is chosen over GITHUB_ACCESS_TOKEN if both exist. |
<Accordion title={<span>How <code>bun create</code> works</span>}>
When you run bun create ${template} ${destination}, here’s what happens:
IF remote template
registry.npmjs.org/@bun-examples/${template}/latest and parse itregistry.npmjs.org/@bun-examples/${template}/-/${template}-${latestVersion}.tgz${template}-${latestVersion}.tgz into ${destination}
--force is passedIF GitHub repo
${destination}
--force is passedELSE IF local template
Open local template folder
Delete destination directory recursively
Copy files recursively using the fastest system calls available (on macOS fcopyfile and Linux, copy_file_range). Do not copy or traverse into node_modules folder if exists (this alone makes it faster than cp)
Parse the package.json (again!), update name to be ${basename(destination)}, remove the bun-create section from the package.json and save the updated package.json to disk.
bun-framework-next to the list of dependencies/src/index.{js,jsx,ts,tsx} to public/index.htmlbun-macro-relay so that Relay worksAuto-detect the npm client, preferring pnpm, yarn (v1), and lastly npm
Run any tasks defined in "bun-create": { "preinstall" } with the npm client
Run ${npmClient} install unless --no-install is passed OR no dependencies are in package.json
Run any tasks defined in "bun-create": { "postinstall" } with the npm client
Run git init; git add -A .; git commit -am "Initial Commit";
gitignore to .gitignore. NPM automatically removes .gitignore files from appearing in packages.development
Using TypeScript with Bun, including type definitions and compiler options
development
Learn how to write tests using Bun's Jest-compatible API with support for async tests, timeouts, and various test modifiers
testing
Learn how to use snapshot testing in Bun to save and compare output between test runs
testing
Learn about Bun test's runtime integration, environment variables, timeouts, and error handling