๐ Bun 1.0's Rocking the Scene & Expo Router's Bringing the Heat ๐ฅ
Published 2 years 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 StepZenโIntimidated 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 ๐
|