Slide 1

Slide 1 text

πŸ›„ VS πŸ“³ NEXT 13 SERVER COMPONENTS Another CodingWithCallumℒ️ Session ⚑️ lightning talk ⚑️

Slide 2

Slide 2 text

πŸ›„ SERVER COMPONENT A component that is fetched and rendered ON THE SERVER

Slide 3

Slide 3 text

πŸ“³ CLIENT COMPONENT A component that is fetched and rendered ON THE CLIENT

Slide 4

Slide 4 text

EXAMPLES

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

USING SERVER COMPONENTS πŸ›„ Only download HTML built by the server Instant render Speed πŸƒβ€β™€οΈπŸ’¨ + the JS required for the client components (if any) react cached Make direct API calls (server to server)

Slide 7

Slide 7 text

NOT USING SERVER COMPONENTS πŸ“³ Install all JS Dependencies to run the site React etc. Then grab all our Client JS Components Then render

Slide 8

Slide 8 text

WHEN TO USE SERVER πŸ›„ VS CLIENT πŸ“³ COMPONENTS Need to access browser related stuff = Client Component Anything Else? = Server Component

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

INTERLEAVING

Slide 11

Slide 11 text

HOW DO I DEFINE A CLIENT πŸ“³ COMPONENT 'use client'; import { useState } from 'react'; export default function Counter() { const [count, setCount] = useState(0); return (

You clicked {count} times

setCount(count + 1)}> Click me

Slide 12

Slide 12 text

);

Slide 13

Slide 13 text

SHARED COMPONENT πŸ›„πŸ“³ What if something is Server And Client Wait what?

Slide 14

Slide 14 text

SHARING DATA FROM πŸ›„ SERVER TO πŸ“³ CLIENT Make your API requests on the server Keep as many dependencies on the server as possible Eg. pass i18n translations from server > client to avoid client code (prop drilling in this case is OK)

Slide 15

Slide 15 text

MUTATING DATA ON THE πŸ“³ CLIENT RPC from the client This will change Next is working on a RFC on this at the moment We will go with what their suggestion is Watch this space

Slide 16

Slide 16 text

READ THE DOCS! Next 13 Server And Client Components

Slide 17

Slide 17 text

No content