Files
bun.sh/templates
Colin McDonnell d348ec0668 Update readme
2023-05-15 15:02:17 -07:00
..
WIP
2023-04-17 17:38:41 -07:00
2023-04-17 22:06:07 -07:00
2023-04-17 21:11:14 -07:00
WIP
2023-04-17 17:38:41 -07:00
2023-04-17 22:02:05 -07:00
2023-04-17 20:03:02 -07:00
2023-05-15 10:53:59 -07:00
2023-05-15 15:02:17 -07:00
2023-04-17 22:02:05 -07:00
2023-04-17 22:06:07 -07:00
2023-04-17 21:11:14 -07:00
WIP
2023-04-17 17:38:41 -07:00
WIP
2023-04-17 12:57:19 -07:00
WIP
2023-04-17 12:57:19 -07:00
2023-04-17 22:06:07 -07:00
WIP
2023-04-17 17:38:41 -07:00
WIP
2023-04-17 17:38:41 -07:00
WIP
2023-04-17 17:38:41 -07:00

Templates for bun create

This repo contains the templates for bun create.

Usage

Refer to the Bun docs for complete documentation of bun create.

To see a list of all official templates:

$ bun create

To scaffold a new project using a particular template:

$ bun create <template> <dir>

To scaffold a new project using a GitHub repo as a template:

$ bun create user/repo <dir>

Creating a template

Fork this repo and add your template to the templates directory. The name of the directory will be the template name. For example, if you add a template named my-template, you can scaffold a new project using it with:

$ bun create my-template <dir>

In the package.json, set the "name" field to the pattern @bun-examples/<name>. The template code will be auto-published to npm using this name, where it will later be downloaded by bun create.

{
  "name": "@bun-examples/my-template"
}

The package.json can also contain some initialization logic in the "bun-create" field. This defines a set of hooks that bun create will run immediately after scaffolding a new project.

{
  // other fields
  "bun-create": {
    "preinstall": "echo 'Installing...'",
    "postinstall": ["bun install"], // accepts array of commands,
    "start": "bun run server.ts"
  }
}

The "start" field is not executed, but it will be printed when a user scaffolds a new project using your template.

$ bun create my-template <dir>
# ...
Created my-template project successfully
# To get started, run:

  cd <dir>
  bun run server.ts # <- copied from the "start" field