ItzDerock / bun-elysia-nextjs

Demo showing Bun + Elysia + NextJS (app dir)

Home Page:https://bun-elysia-nextjs-production.up.railway.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bun + ElysiaJS + NextJS

demo-video-bun.mp4

Demo Deployment

A sample project showing ElysiaJS running as the Next.JS custom server with full end-to-end typesafety similar to tRPC and ts-rest. You get to define the route paths (unlike with tRPC) and no extra boilerplate is needed (unlike with ts-rest contracts). All running on the fast bun runtime.

You can access Bun globals in React Server Components (for example, Bun.password, Bun.file). Hot Module Reloading is also supported.

Tested with bun v1.0.4

Production Deployment

Simply run bun build and wait for NextJS to build the pages. Then you can start the server in production mode with bun start or run the entrypoint with NODE_ENV set to production. This will serve the built NextJS pages from the .next folder in the process's cwd.

Based on my measurements, this basic app uses 0% CPU on idle and ~280MB of RAM on start. This is compared to normal Node.JS which uses ~400MB for a similar sized app.

On Railway (nixpacks)

Railway is a simple cloud deployment platform and with their Nixpacks builder, you can deploy this project with a single click. On their dashboard, just connect your GitHub repo and sit back and relax.

With Docker

soon™️

About

Demo showing Bun + Elysia + NextJS (app dir)

https://bun-elysia-nextjs-production.up.railway.app/


Languages

Language:TypeScript 93.3%Language:CSS 5.1%Language:JavaScript 1.6%