npm create vite@latest my-app -- --template react. Vite builds your app into dist, and the Bunny CLI detects it as a Vite project. If you use React Router in framework mode, follow the React Router guide. For Next.js, follow the Next.js guide.
Configure React
If you use React Router,createBrowserRouter() gives you clean URLs such as /about. Those need the client-side routing fallback described below. createHashRouter() works without it.
Deploy your site
- Bunny CLI
- Manually
1
Install the Bunny CLI and log in
2
Create a site
From your project root, run:Replace
my-site with a name for your site. The CLI creates a storage zone for your files and a pull zone to serve them, then links this directory to the new site. The site is served at a b-cdn.net address, and the CLI prints the URL.3
Build and deploy
bunny sites deployments publish --previous.4
Deploy on every push (optional)
.github/workflows/bunny-sites.yml that deploys the site on every push to main. Add your API key to the repository as a BUNNYNET_API_KEY secret. The CLI offers to run gh secret set BUNNYNET_API_KEY for you.Client-side routing
Single-page apps handle routing in the browser, so a direct visit to a path like/settings needs to load index.html.
The Bunny CLI turns this on for you when it detects a single-page app, unless your build includes a 404.html. To change it, set "spa" in the sites block of bunny.jsonc, or pass --spa or --no-spa to bunny sites deploy.
For a manual deploy, open your storage zone’s Error handling page, set 404 File path to /index.html, and check Rewrite 404 to 200 status code. See Storage zone settings for details.
Add a custom domain
With the Bunny CLI, add the domain to your site:CNAME record to create with your DNS provider. Once the record resolves, issue a free certificate with bunny sites domains ssl example.com.
For a manual deploy, add the hostname to your pull zone by following Custom hostnames.