bun create
bun create
is a new subcommand that lets you quickly create a project from a template.
To create a new React project (based on Create React App)
bun create react ./app
11x faster than yarn create react app
on my Macbook Pro (both installing dependencies via yarn)
To create a new Next.js project (based on Create Next App)
bun create next ./app
To create from a GitHub repository:
bun create jarred-sumner/calculator calc
To see a list of templates:
bun create
Right now, there are only two "official" templates (and they're mostly empty) – but you can add more. bun create
fetches from packages published in the examples
folder of Bun's GitHub repo. PRs are very welcome!
Local templates
Many developers have boilerplate code copied for new projects.
That's why bun create
also searches $HOME/.bun-create
for local templates.
Add a folder with a package.json in $HOME/.bun-create/my-local-template
and then you can run:
bun create my-local-template ./foo
This copies the contents of my-local-template
, initializes a git repository, runs any preinstall steps, installs dependencies (if any exist), runs any postinstall steps and rewrites the name
field in package.json
to foo
.
It uses the fastest system calls available for copying files. bun create
copies files faster than cp
. Here is a stupid microbenchmark
Performance
The slowest part is running your NPM client to install node_modules
. The second slowest part is downloading the tarball from GitHub (or NPM if it's from Bun's examples folder). Third is git.
Other stuff
fetch
now supports gzip- https support in
fetch
was completely rewritten to be more reliable. TLS is now powered by s2n-tls fetch
now supportsTransfer-Encoding: chunked
. It didn't before, which was embarrassing.- Set
self
toglobalThis
in Bun.js. This improves compatibility with some npm packages - There are two new test binaries in
misctools/
,tgz
andfetch
.tgz
is likegunzip
except harder to use andfetch
is sort of likecurl
? These are really just to help me test some things in isolation from the rest of Bun