1 of 62

2 of 62

Facundo Giuliani�@facundozurdo

DevRel Manager @ Storyblok

React Buenos Aires Organizer

DevSummit AR Organizer

3 of 62

4 of 62

5 of 62

6 of 62

7 of 62

Browser

Web Server

8 of 62

9 of 62

But…

10 of 62

https://remix.run/

11 of 62

Content Delivery Network

12 of 62

Group of geographically distributed servers that speed up the delivery of web content by bringing it closer to where users are

13 of 62

https://remix.run/

14 of 62

  • Reduced bandwidth consumption�
  • Better performance�
  • More security

15 of 62

THIS IS NOT A PAID ADVERTISEMENT

16 of 62

17 of 62

18 of 62

19 of 62

20 of 62

21 of 62

Static Content

22 of 62

Static Site Generation

23 of 62

Jamstack

24 of 62

But…

25 of 62

Static Content

26 of 62

https://remix.run/

27 of 62

The Edge

28 of 62

Distributed network architecture in which client data is processed as close to the originating source as possible

29 of 62

https://remix.run/

30 of 62

THIS IS NOT A PAID ADVERTISEMENT

31 of 62

32 of 62

33 of 62

Edge <> Serverless

34 of 62

  • No DevOps�
  • Pay for what you use�
  • No under-utility

35 of 62

36 of 62

  • Better Performance�
  • More security�
  • Real-time insights�
  • Easy scalability

37 of 62

  • Personalization�
  • Geo-location�
  • A/B Testing�
  • Security

38 of 62

39 of 62

Edge Functions

40 of 62

Serverless scripts and functions that execute server-side rendering code and can be distributed to different regions

41 of 62

Edge Functions run on the Edge Runtime (built on top of the V8 engine, Web Standard APIs)

42 of 62

import { NextResponse } from "next/server";

export const config = { runtime: "edge" };

export default (request) => {

return NextResponse.json({

name: `Hola! You are visiting from ${request.url}`,

});

};

43 of 62

export default async function handler(req, res) {

const { id } = req.query;

const response = await fetch(`https://api.mywebsite.com/users/${id}`);

const userData = await response.json();

res.status(200).json(userData);

}

44 of 62

Middleware

45 of 62

Intermediate tier that executes custom logic and tasks before a request is processed

46 of 62

import { NextResponse } from "next/server";

export function middleware(req) {

const userAuth = req.headers.get('authorization');

const url = req.nextUrl;

if (isSubscribed(userAuth)) {

return NextResponse.next();

}

url.pathname = "/api/auth";

return NextResponse.rewrite(url);

};

47 of 62

import { NextResponse } from "next/server";

export const config = { matcher: "/products" };

export function middleware(req) {

const isFeatureFlagged = getFlags(req);

if (isFeatureFlagged) {

req.nextUrl.pathname = "/new-page";

return NextResponse.rewrite(req.nextUrl);

}

};

48 of 62

49 of 62

export default function Todos() {

const data = useLoaderData<typeof loader>();

return (

<div>

<TodoList todos={data} />

<Form method="post">

<input type="text" name="title" />

<button type="submit">Create Todo</button>

</Form>

</div>

);

}

50 of 62

export async function action({ request }) {

const body = await request.formData();

const todo = await fakeCreateTodo({

title: body.get("title"),

});

return redirect(`/todos/${todo.id}`);

}

export async function loader() {

return json(await fakeGetTodos());

}

51 of 62

NextGen Edge

52 of 62

Define different levels of dynamism on a per-route basis. Supports different runtimes (Node, Edge, Deno)

53 of 62

import { json } from "@vercel/remix";

export const config = { runtime: "edge" };

export async function loader({ request }) {

return json({ ... })​;

}

54 of 62

55 of 62

Edge Functions

56 of 62

57 of 62

Cloudflare Workers

58 of 62

59 of 62

Platform-as-a-service for running full stack apps and databases

60 of 62

The Edge is here, and it’s the future

61 of 62

62 of 62

Gracias!

@facundozurdo

https://fgiuliani.com