🚀 Meet Bun 1.0: The New Cool Kid on the block
Published a year ago
|
Hey {{ subscriber.first_name }} 👋 I just came back from a short family trip in the Romanian Mountains ⛰️, and was excited to see a lot of new announcements in the Javascript world. In this issue, we will cover: 😎 The new cool kid on the block: Bun 1.0 🙈 API Routes coming to Expo Router V3 💡 An easy trick to get 50 GB of free storage This issue is sponsored by IBM StepZenIntimidated by GraphQL? 😱 With IBM StepZen you'll be impressed how easy it is to build GraphQL APIs. All you have to do is run a CLI command ($ stepzen import), and the rest is done by IBM StepZen. It connects with a wide range of data sources such as SQL databases, Rest APIs, and even other GraphQL APIs. I've personally used it in multiple projects (Spotify, StackOverflow, LinkedIn) and it saved so much time. Let IBM StepZen take care of the boring stuff so that you can focus on building impactful apps 🚀 😎 What’s up with Bun 1.0?Bun 1.0 was released at the beginning of this month, and it got a lot of attention in the Javascript community. Is it just hype, or is it here to revolutionize how we build and deploy Javascript apps? What is Bun?Bun is everything you need to build and run Javascript and Typescript applications. It’s the Swiss knife that can do everything: run, build, test, debug, transpile, test, etc. The best part about it is that it’s really fast⚡ The problem Bun is trying to solve is the complex and fragmented toolchain we need nowadays to build javascript/typescript apps. For example, a simple NodeJS app needs:
All of these tools not only make everything more complicated for developers but also slow down the whole process of developing apps. Everything works independently, and sometimes the same step has to be executed multiple times. Javascript RuntimeBun is a drop-in replacement for NodeJS, and it is compatible with “any” NodeJS app. It supports the most popular frameworks like Express, NextJS, Astro, Next.js, etc. NodeJS is built using Google’s V8 engine that powers Google Chrome. Bun is built using Apple’s WebKit engine that powers Safari. It can run Javascript, Typescript, and event JSX/TSX files without any additional dependencies. Package ManagerBun is also a package manager like NPM or YARN. In simple words Test runnerBun is also a test runner that can replace Jest. It has the same concepts as jest (describe, test, expect), but it runs much faster. Bun for React NativeHow does this affect us - React Native Developers? When it comes to the runtime, React Native is using Hermes, which is a javascript runtime optimized for mobile. I don’t think there will be any changes to this in the near future. However, Bun as a package manager is something that we can start using right away and benefit from faster installation and execution times. Bun for ExpoExpo just announced that they added support for Bun on Expo CLI and EAS. That means that we can create expo apps, install packages, run scripts, and build our app on EAS using Bun. Try it out by running 🙈 API Routes in Expo Router V3Evan Bacon, the author of Expo Router, published a new RFC for an exciting new feature that is coming to Expo Router V3: API Routes. This will allow us to build full-stack apps, without leaving our Expo project. The API Routes will enable developers to safely run server-side logic, without having to manage 2 separate projects for the mobile and the backend. On the server side, you can do everything from interacting with the database, authorizing users’ requests, to safely interacting with 3rd party APIs (e.g. OpenAI) without exposing your private keys. A simple use caseYou are building a simple mobile+web app. You have to integrate Stripe for payments. To process payments, you have to generate a Payment Intent using your Stripe private key. The private keys should never be used inside your client-side code. That’s why this should happen on the server. If you don’t have a server, you would have to setup one, just to integrate with Stripe. With API Routes, you would simply create an API route, which will technically be a simple file in your Expo project, export a POST function, and safely create the Payment Intent on the server side using your private key. Inside your Expo app (client side), you will send a post request using Everything lives inside your Expo project. Mobile. Web. And now also Server/Backend. Note: You would still have to deploy these functions, but I am pretty sure that EAS will soon have support to deploy the API routes with one CLI command 🤫 💡 Tip of the dayIf you are like me, building lots of JavaScript projects, most probably your drive is full of Running ‼️ Only delete the node_modules folder from the project that you have created. There are also some system applications using node_modules, that you shouldn’t delete. If you have a folder where you keep all your projects, first navigate there and then run the command. All the information about what packages your project depends on, is kept inside 🔁 In case you missed it
🔥 Press worthy👀 Static Hermes: compile Typescript to native code for better performance 🤖 ChatGPT can now see, hear and speak Did you learn something new today?If you found this email valuable, forward it to one friend or coworker who can benefit from it as well. That would be much appreciated 🙏
|