I Stopped Using Express.js: Because Bun and Hono 🔥
Vložit
- čas přidán 6. 06. 2024
- Express has been around for almost as long as node has existed. It’s an awesome framework, it’s how I learned to make web servers in node and how i’ve been teaching people to make web servers for the past 8 years.
But it’s time to move on, because the alternatives are just so much better. It’s mind blowing how much the web has changed recently.
Chapters:
0:00 Hono
0:42 Bun Server
1:52 Routing
3:33 Streaming
4:18 Middleware
4:50 JSX
6:32 Testing
8:21 Validation
Help support me make more videos: ko-fi.com/meechward
🔗
My Website: www.sammeechward.com
Instagram: / meech_ward
TikTok: / meech.s.ward
X: / meech_ward
Threads: www.threads.net/@meech_ward
Github: github.com/orgs/meech-ward - Věda a technologie
JS developers change frameworks more often than they take a bath.
Amazing video! I don’t know if it’s just me but: being able to write your server logic in Typescript without extra tooling, the fact you can write JSX, just amazing, my only concern with these new and better technologies is compatibility with existing libraries and packages, maybe you could do a video addressing that
amazing demonstration Sam!
looks so cool! I'm gonna try it out for sure, thanks for the info!
Your content is really amazing, i would love to see a vite and hono full fledged tutorial.
i wanted to use hono for a time now but bun and hono combined looks crazy fun. I think the next project will be with bun and hono
Dude, super well paced and explained, mint.
Amazing! We’re waiting for a full Tutorial ;-)
Gratefull, I'll waiting for your tutorial using Hono🤩
that absolutely look great!, would be nice to see hono - monorepo tutorial :D
the use of context reminds me of how Golang Web Frameworks like Gin and Echo work. Pretty nice!
Same here! I was looking for this comment
ok you've sold me!
next project will be with hono (bun i already use :D)
Subscribed for the hono+vite magic that you'll drop
Bro will you make a full stack application using Bun, so that we can learn something from your experience
The way you can learn from this experience is if YOU make a full-stack app using Bun. His knowledge isn’t magically transferred into your head
Is it that you're not sure how full-stack works? Here.
OPEN THE TERMINAL AND RUN
> mkdir HotelTrivago
> cd HotelTrivago
> bun init
> bun install express cors
CREATE FILE CALLED "server.js" IN THE "HotelTrivago" FOLDER THEN BUILD AN API THAT SPITS OUT SOME TEXT USING THE BELOW CODE
START CODE BLOCK
const express = require('express');
const cors = require('cors');
const app = express();
app.use(cors());
app.get('/', (req, res) => {
res.send("Trivago");
});
app.listen(3000, () => {
console.log('listening on port 3000');
});
END CODE BLOCK
BACK TO THE TERMINAL AND START UP THIS BAD BOY
> bun server.js
OPEN BROWSER AND GO TO 'localhost:3000/' AND BEHOLD, OUR SERVER/API HAS RESPONDED WITH THE WORD "Trivago"
NOW WRITE A CLIENT APP THAT USES THIS API ENDPOINT
CREATE AN "index.html" FILE ANYWHERE, OPEN WITH A TEXT EDITOR AND INSERT THIS MARKUP
START MARKUP BLOCK
async function clickityclickity() {
let response = await fetch('localhost:3000');
let data = await response.text();
document.querySelector('p').innerHTML = data;
}
Hotel?
Click Me
END MARKUP BLOCK
NOW OPEN "index.html" WITH A BROWSER
CLICK THE BUTTON AND BEHOLD THE "Hotel?" TURNS INTO A "Trivago"
FULL STACK, BABY
Great video Sam, curious as to which keyboard you're using (i'm trying to find a silent one you can't hear over a microphone), thanks!
It would be great to see the performance part in comparison with express, fastify on node to understand the capabilities of this modern framework
Google is your friend:
"Node.js vs Deno vs Bun: Express hello world server benchmarking"
amazing, seems like something's great is growing out of bun. im excited to see where it will go.
Yo, can't wait for Hono+Vite+React setup tutorial!
I've tried a couple of time to make it works but failed! Can't wait to see the video!
Man just ditch React and Client frameworks once and for all. You have JSX on the server with these. What else do you need?
I'd love to see that too. Where I work, we use Next.js (page router) for a big web app and the DX is terrible. The dev server crashed at least one a day and take close to 2GB of memory. All I care about in Next if getServerSideProps(), so if I could use something lightweight to replace it, that would be awesome.
beth stack but hono
@@jarnathan-snow
It’s here he just posted it. It was more of a walkthrough but so far has been very enjoyable.
we need more Hono videos! this was great!
The problem with this new tech is that the industry doesn't implement it. They stick with the OG tech. So spending time learning something like that could be wasting of time sadly.
yep
It’s pretty straight forward though, anyone with react and express knowledge will pick this up in an hour.
It doesn't take any time to learn this if you already know express. That was the point of bun, to supercede node, express, npm, but actually fast since it runs on zig.
JS developers are sick to be honest they always run for new things without any need, searching for the perfect library or runtime or framework and they never find one or will.
I am a js developer but the community is just too much, and I am not against developing more libraries that are better, but not hundred of solutions for the same problem and most of them are the same
The client/server type safety is a nice feature!
This is great! Is there support to integrate Bun into a AWS lambda runtime and Hono into an AWS lambda proxy?
Hono is awesome! Would love seeing more content on hono
Great, as always. ✌️
Super Cool video! Subbed!
That is very cool I usually use python for backend development but I am excited to try hono and bun
Nice intro! Well done.
What are your thoughts on Hono vs. Elysia? What do you prefer about Hono?
Great video! I would love to see a Hono, Vite, React tutorial.
that is soo good dud, i see yesterday.
Looove hono + bun combo. Also sprinkle some htmx and its pretty magical
Don’t forget drizzle
You know what I have an old express project, I will try migrating it to bun + hono . Want to see what are the gotchas in this combo.
awesome content . subbed :)
Which cli and cli font are you using? I'm so obsessed with the fonts, ain't I?
Yes we would love a tutorial on vite and hono please 🙏
Would be nice to see more vids on this topic
yea i tried this ~ 12 - 18 months ago but couldnt stick w it for larger stuff glad the ecosystem has improved w it
What about the server folder you created at the start, Sam? 😁
While bun is great, Bun is still reliant on one primary developer.
I love bun and will continue to use it for smaller projects or side projects, but until it becomes reliable longevity wise, I prefer to stay with the standard tech for now for business focused work.
Luckily hono supports node too
@@WillDelishtrue
JS developers are sick to be honest they always run for new things without any need, searching for the perfect library or runtime or framework and they never find one or will.
I am a js developer but the community is just too much, and I am not against developing more libraries that are better, but not hundred of solutions for the same problem and most of them are the same
More bun and Hono please! Maybe build full rest api with swagger, mongo and some sort of autorization it is be nice
Tutorial for hono/vite if possible. Idk if you already did it but thanks ahead of timeif you are thinking about it.
Hey sam please make a comparison between Hono and ElysiaJS
im always wanting to try bun , but i don't know if its stable for production yet or not
Hello sam, how about ElysiaJs?
I am absolutely blown away! 😮 This is so much better than Node and Express! If they come up with a framework like Nest or Adonis with bun and hono, it will absolutely dominate the backend world!
Did you ever test elysia i'm looking for something performant and reliable
Could you compare Hono and tRPC? It appears they both have similar capabilities. Thanks!
Outstanding 😊
Hono is beautiful. Been using it so much.
Hah, I'm doing the same! With drizzle orm and vitest it's perfect stack for me.
I wish Bun had Windows and Nextjs support ... hopefully soon
With qwik can be good solution for full stack, how about SSR, IRS kinda things like NextJS. Thanks for tutorial, keep it up 🎉
Damn, Hono looks incredible!
You had me at “Because Bun” it’s always about the bun
Hey Sam! Great video as always! I am curious how this works with bigger projects where I have JSX templates and layouts just like Next, but without all the hassle, it just renders HTML. I would appreciate if you could make a longer video on that.
It’s not opinionated like next, so you would just have to create your own layout components. You could make it work however you want but you wouldn’t get default caching behaviour or default 404 or error pages.
I don't think 404 pages or error pages are that much difficult to handle. But I can't say the same about caching. Caching seems very hard. If you could make a video on caching different parts of your website i.e mixing database caching, CDN caching and all that good stuff, that would be really good. @@SamMeechWard
since i only new about express js, could be more risk to implement this to my project, but i will try my best to use it from my next project
I would like to see this working with vite, it sounds interesting.
One of the issues i still have with the validator is that your validator has to return strings (if you try a number itll just throw a ts error)
I just had to rewrite a small webapp because Flask doesn't handle SSE nicely, and Bun + Hono works so much better. Thanks a lot for showing this setup!
Great content
Have you tried Elysia? The DX is really amazing
it is not. Have you tried nesting guards?
@@jarnathan-snowyh that's a chore but I prefer beforehandle function
Being able to serve HTML using JSX instead of EJS or other template language is so good!!!
Hey Sam, how can we connect to a database while calling APIs
What about elysia? Can you also review that project?
can you also make a video on elysiajs and bun
Thanks!
Wow, this is nice I love hono
Is it sending a Server Sent Event stream with the stream.write stuff?
Would love to see the version with client side
Could you make a video integrating tRPC with hono?
do you think hono is production read?
Is Bun.serve() necessary? when already using bun run --hot src/index.ts??
Hono seems cool, but after Sveltekit I can’t see me using another tool for api
This is DOPE
I'm interested in hono + react app and how the live together and interact
Do you get any memory leaks?
do you have a video about exposing an ML (AI) model thourgh a JS/TS API?
How do you feel about there only being basically 1 contributor to bun? Do you still recommend bun for production even though it doesn't pass the bus test?
Nope use deno …
never tried hono but tried elysia i was a pleasant experience
bun update command not update version numbers in package.json in my local, do you know how to fix it?
How about koa js. It's like similar with hono right ?
error: Cannot find module "react/jsx-dev-runtime" from "/Users/sam/Documents/server/src/app.tsx"
Yes please make tutorial with react and hono
Have they solved Bun not working with SSH-ed25519? I couldn't use Bun due to my SSH dependencies not working with it.
Thanks now I understand why Hono is better that ElisiaJS too 🎉
waiting to watch a vite and hono full fledged tutorial
Hi Sam,
have you built a production app with bun? if yes how has been your experience?
It’s been awesome, only great things to say about using bun. I’ve been deploying to fly.io.
@@SamMeechWard Wow! will definitely try it. Thanks
Definites on what a production app is - if you mean an app with thousands of live users, then Bun isn't stable for that.
@@mdmathewdc Please share your experience.
We have few public API running with bun, it is just great.
how to handle concurrency or multithread using Hono ?
laravel with vue js using inertia js is stll awesome
There’s a Safari bug that prevents Bun web servers from successfully sending binary downloads like images and files to that web browser. 😢
How does it compare to Elysia?
what about security like helmet plugin?
I do trpc with zod and I don't get why I should use hono or bun unless there's a trpc hono adapter
And the fact I get 0 users lol
idea about having context argument instead of req, res is actually convenient
you may want to switch rust/axum it also looks like express but much faster and lightweight than ever, also supports multithreading with tokio
True, but we're in node/js land right now 🥲
Where can this be deployed?
How hono vs Elysia?
It's kinda mix of express.js and golang. But anyway looks so cool and clean
You are going so fast... is hard to follow... but none the less... very valuable content. thanks
In YT you have a great option to slow down the playback speed of a video and also an advanced button called "pause".🤷🏿♀️🤷🏿♀️🤷🏿♀️
@@blender_wiki will this magic button also give all the context that I need? Is not the speed of the video that is fast... but the flow... but thanks for such a lovely condesending and mansplaining comment! We def. need more of these!
Waku synergizes well af
Someone lmk what extension is showing errors right from inline