Serverless for React Developers

Rate this content
Bookmark

Intro to serverless

Prior Art: Docker, Containers, and Kubernetes

Activity: Build a Dockerized application and deploy it to a cloud provider

Analysis: What is good/bad about this approach?

Why Serverless is Needed/Better

Activity: Build the same application with serverless

Analysis: What is good/bad about this approach?

This workshop has been presented at React Summit 2022, check out the latest edition of this React Conference.

FAQ

Serverless computing refers to a cloud computing execution model where the cloud provider runs the server and dynamically manages the allocation of machine resources. The pricing is based on the actual amount of resources consumed by an application, rather than on pre-purchased units of capacity.

Zada is a serverless database that focuses on developer experience, offering a UI with TypeScript client, a playground, and a Visual Studio Code extension. It provides features like full search capabilities, branching for safe database changes, and a globally distributed network.

ISR allows you to update static content after the initial build step on a per-page basis. This means your static pages can be updated without needing to rebuild the whole site, providing faster performance and better SEO while still serving dynamic content.

The 'revalidate' option in ISR specifies the number of seconds after which a page re-generation can occur. Setting it to 'true' or '1' means the page will be revalidated after every request, ensuring users always receive the most up-to-date content.

Edge Functions are similar to traditional serverless functions but are executed closer to the user by running on a globally distributed network. This reduces latency because the functions are run on servers geographically nearer to the end user compared to centralized server locations.

Branching in Zada allows developers to make changes to a database in a safe, isolated environment. This feature lets you create, test, and merge changes without affecting the main database, ensuring that your production environment remains stable.

SSG offers improved load times and better SEO since the pages are pre-rendered at build time. However, it lacks real-time data fetching capabilities, which SSR provides by rendering pages on each request, allowing for dynamic content updates.

Tejas Kumar
Tejas Kumar
107 min
04 Jul, 2022

Comments

Sign in or register to post your comment.

Video Summary and Transcription

The Workshop focuses on building an open-source project using serverless technologies and React. It covers various topics such as choosing serverless approaches, debugging serverless code, working with databases, and creating a data model. The workshop also explores deploying React apps to a serverless setup, server-side rendering, and static site generation. It discusses the benefits of serverless, the use of Zada as a serverless database, and the concept of edge functions. Overall, the workshop provides a comprehensive overview of working with serverless and React for modern front-end development.

1. Introduction to Serverless and React

Short description:

The plan is to build an open source project in this workshop. Serverless is named as it is because, as a developer, you never touch a server. Instead, you interact with an API. React and serverless are both abstractions that simplify complexity. You can model servers without actually having to deal with them.

I would like to start with... so just an overview for you, the plan is to build a project, an open source project. This project is not going to benefit me or my company in any way. It's just to learn together. And it's a workshop.

By workshop, I mean we're working, but we're doing interactive shit. It's not like a three-hour-long talk where you turn off your video and fall asleep and then come back at the end to say, wow, great job. Meaning it's misnamed. It's a lie, is what Wikimedia says. And the presumption there is it's a lie because there's actually servers.

So it's not server-less. But really, serverless is named as it is because to you as a developer, it is serverless. You're not the one managing the servers. You're not maintaining the servers. You're not scaling the servers. You're not implementing strategies for failover for the servers. So for the developer, it is serverless in that you never touch a server. Instead, what do you touch? You touch an API. Literally an API, an application platform interface, an interface into someone else's server. That is it.

How does it connect to React? React is a level of abstraction on the imperative browser DOM, the document object model. Like React is just a bunch of functions that have state that map to elements in your browser. Serverless is similar because serverless is nothing more than abstraction. The servers and their complexity are abstracted away. You could put React as JSX in JavaScript to model the DOM. There's ways you can also model servers without actually having to deal with them.

2. Choosing Serverless Approach

Short description:

You can choose your own adventure in this workshop. There are two ways to approach serverless: looking at it under the hood and building servers, or using existing serverless solutions in a React app. The latter option focuses more on React and provides transferable skills for modern front-end development. Pick your choice by writing one or two in the chat.

Excellent. From what you wanted to learn, I received that, Matt. You mentioned you wanted to learn strategies and recipes and cookbooks on building with serverless. I think that's really helpful. Because I wanted to do this workshop in a way where you can choose your own adventure. And there's usually two ways this can go. I'm gonna need you to pay attention here. Because this will literally affect the entire workshop. You get a very different workshop if you fuck this up. It can either be... We look at serverless under the hood. So we build, maintain, provision, scale servers. And so we kind of understand serverless from that way by actually creating servers and doing the work that AWS would do. Or we use existing serverless solutions and compose them together in a React app. The latter is definitely more React-focused, less like backend infrastructure-focused. And will actually give you, I think, in my opinion, more transferable-slash-useful skills in the modern front-end React world. Because how people build apps today is, for example, if you're building a React app, you'd probably connect to Auth0 for authentication. You'd use some type of serverless database, like Zada. You'd compose different serverless providers. And then have your React app also server render or serverless render in its own way. So there's rendering strategies and things that React can talk about that would help you more meaningfully. The other one is more information that you learn about how things work. But you probably will never use professionally because there's people who work at AWS that's their full-time job, okay? So if that's clear, pick your own adventure by writing in the chat one for the serverless behind the scenes and two for composing serverless things in React.

QnA