Open source · MIT · Self-hosted

The React framework you host yourself.

File-based React pages rendered on Bun. API routes written in Go. Types that cross from one to the other on their own. All of it on one box you control, with no platform underneath.

Get started
Rendered from this serverborgo 1.1.0 on Go 1.27.0up 3m 33s1 reader here now

Three ideas

A village, not a platform.

1

The pages are React

Unmodified React, one toolchain. Drop a file in pages/ and it is a route, with loaders, layouts, form actions and client navigation. No fork, no compiler magic, no bundler config to own.

2

The server is Go

A static binary on net/http answers the port: your API, your static files, your event streams. Bun renders the pages behind it. The process that pages you at 3 a.m. is the boring one.

3

The types cross on their own

borgogen reads your handlers and writes the TypeScript: routes, responses, request bodies, WebSocket payloads. No OpenAPI spec to keep honest, because the code is the spec.

The typed bridge

Rename a field in Go. Watch the page stop compiling.

Take the three steps yourself. Hover a field to see where it lands on the other side.

A Go handler answers with a Note. borgogen reads it and writes the TypeScript type; the page's loader is typed without declaring anything.

api/notes.go
type Note struct {
  ID    int    `json:"id"`
  Title string `json:"title"`
  Done  bool   `json:"done"`
}

//borgo:route GET /api/notes/{id}
func GetNote(w http.ResponseWriter, r *http.Request) {
  note := find(r.PathValue("id"))
  borgo.JSON(w, http.StatusOK, note)
}
pages/notes/[id].tsxtsc: clean
export async function loader(ctx: LoaderContext) {
  const note = await ctx.api("GET /api/notes/{id}", {
    params: ctx.params,
  });
  // note: { id: number; title: string; done: boolean }
  return { heading: note.title, done: note.done };
}

How the bridge reads your Go, and where it stops →

Try it, on this server

The rules live in Go. The form just listens.

This form posts to a Go handler running on the machine that served you this page. Get it wrong: the answer is a 422 with a map of fields, and the page shows, beside each field, what Go said about it.

Leave a field empty, or say you come from Vercel, and see what Go answers.

POST /api/greetwaiting
// what the Go handler answers
// will appear here
api/greet.go, abridgedapi/greet.go on GitHub
// asked by borgo.BindValid, after the body is decoded
func (a Arrival) Validate() error {
	bad := borgo.Invalid{}
	if strings.TrimSpace(a.Name) == "" {
		bad["name"] = "the gatekeeper needs a name"
	}
	if strings.EqualFold(a.From, "vercel") {
		bad["from"] = "you can stay, but you host yourself here"
	}
	return bad.OrNil()
}

//borgo:route POST /api/greet
func Greet(w http.ResponseWriter, r *http.Request) {
	a, err := borgo.BindValid[Arrival](r)
	if err != nil {
		borgo.BindError(w, err) // 422 {error, fields}
		return
	}
	borgo.JSON(w, http.StatusOK, welcome(a))
}

In the box

Everything else you expect is a file convention.

Quickstart

Five lines to a running app.

You need Bun 1.4 or later and Go 1.27 or later. Three templates: base is a tour of loaders, actions, islands and SSE; minimal is one page and one route; full is notes on SQLite with auth, middleware, a cached page and typed WebSockets.

From here to a working feature, in about half an hour →

your terminal
bunx create-borgo@latest my-app
cd my-app
bun install
go mod tidy
bun run dev
A room in piazza: the village skyline above, rooms on the left, a conversation with reactions

Built with borgo

piazza: a whole team chat, on one small server.

Workspaces, rooms, threads, files, search, realtime, a second step at sign-in, sign-in through an identity provider, bots and webhooks, in nine languages. It is the largest thing built with borgo, and its stress test: what was hard to build there changed the framework.

Open piazzaRead its sourceSee the showcase

Measured, with the biases first

Server-rendered pages, per second.

One laptop, a harness written by borgo's own author, and 11 of 27 comparisons that drifted between two sweeps by more than their own noise. The three documents are not the same size either. Read it for what it is, then run it yourself.

Every scenario, including the ones borgo does not win →

  • borgo4,855 req/s
  • Astro 52,831 req/s
  • Next.js687 req/s

Said plainly

What borgo is not.

Everything here is a deliberate choice, with its reason and its bill attached.

  • No React Server Components

    Loaders returning serialized props are the model, with a runtime small enough to read.

  • No edge or serverless targets

    One box, two processes, a reverse proxy. borgo will not deploy you to someone else's runtime.

  • No plugin system

    The framework is small enough that the extension mechanism is reading the source and changing it.

  • Auth is mechanics, not policy

    Cookies, hashing, handlers and CSRF are provided. The user store, OAuth and everything beyond stay in your hands.

Every position, argued: why borgo works this way →

Small, self-governing, self-hosted.

You can read the whole thing: roughly thirty thousand lines of TypeScript and Go, comments included, with the reasoning threaded through them.

Get startedStar it on GitHub

Built by Luigi Micca. The case study, why borgo exists and what building it taught him, is on his site.