diff --git a/docs/bundler/fullstack.md b/docs/bundler/fullstack.md index 7b1b9185d6..967f3258c4 100644 --- a/docs/bundler/fullstack.md +++ b/docs/bundler/fullstack.md @@ -68,19 +68,53 @@ Bun.serve({ When you make a request to `/dashboard` or `/`, Bun automatically bundles the ` + + + +``` + +Becomes something like this: + +```html#index.html + + + + Home + + + +
+ + + +``` + ### How to use with React To use React in your client-side code, import `react-dom/client` and render your app. {% codetabs %} -```ts#backend.ts +```ts#src/backend.ts import dashboard from "./dashboard.html"; import { serve } from "bun"; serve({ static: { - "/": homepage, + "/": dashboard, }, async fetch(req) { @@ -90,7 +124,7 @@ serve({ }); ``` -```ts#frontend.tsx +```ts#src/frontend.tsx import { createRoot } from "react-dom/client"; import { App } from "./app.tsx"; @@ -100,26 +134,32 @@ document.addEventListener("DOMContentLoaded", () => { }); ``` -```html#dashboard.html +```html#public/dashboard.html Dashboard - +
- + ``` -```css#styles.css +```css#src/styles.css body { background-color: red; } ``` +```tsx#src/app.tsx +export function App() { + return
Hello World
; +} +``` + {% /codetabs %} ### Development mode