A Glimpse Into the Future of Fullstack Development with Blitz.js

Rate this content
Bookmark

Blitz was created as a fullstack React framework, inspired Ru on Rails, and with a goal to make you as productive as possible! It features a ""Zero-API"" data layer abstraction, has authn & authz out of the box and a few more exciting features. However, we recently decided to pivot Blitz to a framework agnostic toolkit, which means a huge and thrilling change for the Blitz community. During this talk, I will introduce the core concepts, talk about the why & how of the pivot, and give you a glimpse of Blitz's future.


You can check the slides for Aleksandra's talk here.

This talk has been presented at Node Congress 2022, check out the latest edition of this JavaScript Conference.

FAQ

Bleeds.js is a full-stack React framework inspired by Ruby on Rails, built to empower developers with a seamless experience for building full-stack and React applications. It is built on top of Next.js, adding functionalities like direct database access, middlewares, authentication with authorization, and more.

Bleeds.js is currently maintained by Aleksandra, who previously led the Hasura console team.

Some core features of Bleeds.js include zero API layer, direct database access using Prisma, automated configuration for tools like Slint, Pretier, Husky, TypeScript, Jest, and built-in authentication and authorization.

Bleeds.js allows you to run server code directly from the frontend by abstracting the API into a build step. It uses server functions called Bleeds resolvers, which are plain JavaScript functions that run on the server. During build time, an auto-generated JSON API layer is created.

The future direction of Bleeds.js includes transitioning to a framework-agnostic toolkit that preserves its developer experience and features. The new toolkit aims to support frameworks like Remix, SvelteKit, and Nuxt, and will offer features such as JWT authentication, websockets, background processing, and more.

Bleeds.js provides built-in authentication and authorization out of the box. It includes code for creating new accounts, logging in, and logging out. Additionally, there is a Passport.js adapter for third-party logins, and secure password hashing and session management are configured by default.

Bleeds.js recipes are inspired by Gatsby and provide an easy way to extend applications. They allow you to add UI libraries, deployment tools, logging tools, and more to your Bleeds.js application.

The zero API layer in Bleeds.js eliminates the need for a separate REST or GraphQL API to connect the React frontend with backend services. It allows server code to be called directly from the frontend, simplifying the development process.

Developers can get started with Bleeds.js by installing it globally and running the 'Bleeds new' command. They will be prompted to provide a project name and answer questions about their preferred settings, such as JavaScript or TypeScript, form libraries, and package managers.

Existing Bleeds.js projects will continue to run, and any critical bugs will be fixed. The transition to the new toolkit is designed to be as seamless as possible, with code modes to automate necessary changes. The effort on the user's part for migration should be minimal.

Aleksandra Sikora
Aleksandra Sikora
32 min
18 Feb, 2022

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Today's Talk introduced Bleeds.js, a full-stack React framework built on top of Next.js. It eliminates the need for an API layer, allowing server code to run directly from the frontend. The Blitz framework is pivoting towards a framework-agnostic toolkit to bring more people to Bleeds and decouple it from any specific runtime. The new Bleed toolkit will include core features like zero API data layer and authentication, with additional features like JWT authentication and advanced data-aware authorization. The audience showed interest in the Blitz Pivot concept and the ETA for the stable 1.0 release is the end of March.

1. Introduction to Bleeds.js

Short description:

Today, I'm going to talk about the future of full-stack web development with Bleeds.js. Bleeds is a full-stack React framework built on top of Next.js. It includes direct database access, middlewares, authentication with authorization. One of the core concepts is that Bleeds is monolithic. The most significant feature is the zero API layer, allowing you to run server code directly from your frontend.

Today, I'm going to talk about the future of full-stack web development with Bleeds.js. I will introduce you to what Bleeds currently is, and I will give you a glimpse into what is going to be in the future. My name is Aleksandra and I'm currently maintaining Bleeds, and previously I led a Hasura console team. You can find me on GitHub and Twitter, and you can also check out my personal website.

The agenda for today is to talk about the past, the current state, and the future of Bleeds. We'll go through the core concepts and features, and then I will explain what are our plans and what we are currently working on. Some of you might have already heard about Bleeds, or maybe you even used it in your projects. For those who didn't, Bleeds is a full-stack React framework. It was hugely inspired by Ruby on Rails, and built with a motivation to empower developers and give them the best possible experience for building full-stack and React applications. Bleeds is built on top of Next.js. Next is a framework mostly focused on the frontend, where Bleeds adds all the missing features and functionalities that turn it into a full-stack framework. It includes direct database access, middlewares, authentication with authorization. For the setDatabaseAccess, Bleeds is using Prisma, by default. It's a batteries-included framework, which means that all the boring things like Slint, Pretier, Husky, TypeScript, Jest, are already there configured for you. You can go straight to writing the business logic and shipping your products.

One of the core concepts is that Bleeds is monolithic. It means that you can reason about your application as a single entity. There's only one thing to develop, deploy, and think about. Now, let's talk about some of the core features. The most significant one is the zero API layer. If you're using React, it requires you to have REST or GraphQL API to connect to database or perform some business logic which is meant to be performed on the server. You need an API, even if it's not going to be used by third parties apart from your own application. Build times is also a source of complexity and sometimes it could be avoided. BLEEDS allows you to run server code directly from your frontend. How does it happen? So BLEEDS abstracts the API into a BUILD step. You can use the SERVER function in your frontend and BLEEDS will swap the import with an HTTP call at build time. The server functions are called BLEEDS resolvers and we have queries and mutations. However, they are just plain JavaScript functions, which will always only run on the server. Also, you can still add your own API if needed, and BLEEDS won't get in your way. Let's take a look at the architecture diagram.

2. BLEEDS Server Code and Queries

Short description:

At the top, we have client code and server code at the bottom. With BLEEDS, you can have a server-side rendered and a client-side rendered page next to each other. The middle layer is an auto-generated JSON API that exposes each query and mutation at a unique URL. We use Prisma to find the project with a given ID in the database. In a component, we use the useQuery function for queries and the useMutation function for mutations.

At the top, we have client code and there's server code at the bottom. In particular, we have one query and one mutation at the bottom. In your application, you can have a server-side rendered and a client-side rendered page next to each other. With BLEEDS, they can use the same server code. In build time, the middle layer is generated and inserted for you.

The middle layer is this auto-generated JSON API on the diagram. Each query and mutation is exposed at a unique URL, which means that you can also call those URLs directly, for example, from a mobile application. Here we have a sample BLEEDS query, it's called GetProject. And let's take a look what happens here. So we use that to define the shape of the query parameters. Then we parse the input to make sure that it's what we want. Later, there is a call to the database, we use Prisma here. And with this call, we are trying to find the project with a given ID. At the end, the query returns the project that we were looking for in the database.

In a component, we pass it to a useQuery function imported from Blitz. It's built on top of React Query, which is a great library, providing caching, polling, great developer experience, and many, many more features. Now let's take a look at the mutation example. It's not much different from the previous function. We also define the shape of the input, we parse it, we connect to the database to create a new object, and at the end, we return the newly created project. In a React component, we pass this function to a useMutation and then we use it upon a form submit.