bun-create
TLDR
Create a new project from an official template interactively
Create a new project from an official template in a new directory
Create a new project from a GitHub repository template
Create a new project from a local template
Create a new project, overwriting the destination directory if it exists
Create a new project without initializing a Git repository automatically
Create a new project without installing dependencies automatically
SYNOPSIS
bun create <template-name | user/repo[#branch]> [<project-directory>] [options]
Examples:bun create react my-appbun create nextjs my-next-appbun create honojs my-apibun create github-user/my-template#main my-custom-app
PARAMETERS
<template-name | user/repo[#branch]>
Specifies the source for the new project. This can be the name of a predefined template (e.g., react, nextjs, astro) or a Git repository URL in the format user/repo[#branch]. Bun fetches the template from this source.
[<project-directory>]
The optional name of the directory where the new project will be created. If omitted, Bun often defaults to the template name or prompts for one. If the directory already exists, bun create may exit or prompt for confirmation to overwrite (unless --force is used).
DESCRIPTION
bun-create is an integral subcommand of the Bun JavaScript runtime, engineered for the rapid scaffolding of new projects. It significantly streamlines the project initialization process by enabling users to either select from a curated list of predefined templates or specify a custom Git repository. This command intelligently handles the entire project setup, which typically includes cloning the template repository, installing necessary dependencies using Bun's ultra-fast package manager, and, if defined by the template, executing initial setup scripts. It serves as an indispensable utility for developers aiming to kickstart their Bun, React, Next.js, Astro, or other web development projects with minimal boilerplate. By promoting consistency and drastically reducing manual setup time, bun-create simplifies project creation across diverse frameworks, solidifying its role as a premier tool for modern JavaScript and TypeScript development workflows.
CAVEATS
- Network Dependency:
bun createrequires an active internet connection to fetch templates, whether they are predefined or custom Git repositories. - Template Specificity: The behavior and prompts during project creation can vary significantly based on the chosen template. Some templates may ask for additional configurations (e.g., TypeScript, ESLint setup).
- Existing Directory: If the specified
project-directoryalready exists and is not empty,bun createwill typically error out unless the global--forceoption is used to explicitly overwrite the contents. - Bun Installation: The Bun runtime must be installed and accessible in the system's PATH for this command to function.
<B>POPULAR TEMPLATES</B>
Bun supports a growing list of official and community-contributed templates. Some commonly used ones include react (for Vite/React), nextjs, astro, hono, svelte, express, and elysiajs. These templates offer pre-configured setups for various application types.
<B>CUSTOM TEMPLATE USAGE</B>
Beyond predefined templates, bun create allows developers to bootstrap projects from any Git repository. By specifying a user/repo path (e.g., my-org/my-starter-template), Bun will clone the repository. You can also specify a specific branch using #branch-name (e.g., my-org/my-template#dev). This provides immense flexibility for organizations to maintain their own starter kits.
HISTORY
The bun create command has been a fundamental component of the Bun CLI since its early public releases (circa 2022). Its design ethos closely mirrors Bun's overall focus on speed and developer experience, providing a modern alternative to traditional JavaScript project scaffolding tools. It continuously evolves with the Bun runtime, adapting to new web standards and popular frameworks to ensure a smooth and efficient project setup process.


