/bun-netlify

Example of React app that you can deploy to netlify using bun (bun.js, oven.sh)

Primary LanguageHTML

React with Bun runtime

This is a React project bootstrapped with bun.

Getting Started

Cloning the repo

bun create react ./react-bun-app

Development

First, run the development server.

bun dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying src/App.jsx. The page auto-updates as you edit the file.

Prepare for builds

For vite checkout vite branch

Add react-scripts to devDependencies:

bun add react-scripts -d

Build locally to add browserslist to package.json:

bun react-scripts build

Connect to netlify

make sure to connect your repo to github and netlify to enable automatic builds.

ntl init

Edit netlify.toml:

[build]
  # custom build command that install bun and run build
  command = "./scripts/build.sh"
  # CRA output folder
  publish = "build"

[build.environment]
   # disable NPM install
   NPM_FLAGS = "--version"

Edit scripts/build.sh:

#!/bin/bash
set -e
curl -fsSL https://bun.sh/install | bash
export PATH="/opt/buildhome/.bun/bin:$PATH"
bun --version
bun install
bun react-scripts build

Deploy

Just push to github and netlify will build and deploy your site.

Learn More