My Weird Journey To Next.js

Theo - t3․gg
20 Jun 202424:28

Summary

TLDRIn this video, the creator shares his personal journey with Next.js, a framework he initially disliked but later embraced as the future of web development. He discusses his background in programming, his transition from backend to frontend, and his love for functional programming. The creator details his frustration with the slow process of backend and frontend synchronization and how Vercel's server components, especially the introduction of async support, revolutionized his workflow. His passion for the seamless integration of server and client-side code in one project, along with the efficiency of Vercel's deployment process, transformed him into a staunch advocate for Next.js.

Takeaways

  • 😀 The speaker's journey with Next.js started with a love for functional programming languages, which led to an appreciation for the framework's ability to integrate backend and frontend code in a single project.
  • 🔧 The speaker initially disliked JavaScript and frontend work but eventually fell in love with React and its component model after being pushed to contribute to Twitch's frontend rewrite.
  • 📚 The importance of a well-defined API layer was highlighted through the speaker's experiences at Twitch, emphasizing the need for synchronization between backend and frontend teams.
  • 🚀 The speaker's frustration with slow development cycles and the inability to quickly iterate led to the exploration and adoption of Vercel Functions and later, Next.js for their project needs.
  • 🛠️ The speaker's initial use of Vercel Functions (then called API Directory) allowed for the addition of backend functionality to a frontend project without needing to change the framework or setup.
  • 🔄 The transition to Next.js was driven by the need to reduce build times and improve performance by bundling multiple endpoints into a single Lambda function, enhancing the deployment process.
  • 💡 The introduction of tRPC simplified the speaker's codebase significantly, allowing for type-safe and efficient data fetching and server-client communication.
  • 🌐 The speaker's advocacy for the T3 stack (Tailwind, TypeScript, tRPC) and its popularity among the developer community demonstrated the appeal of combining these technologies for building applications.
  • 🎥 The speaker's YouTube channel took off quickly, leading to sponsored content opportunities and collaborations with companies like Vercel, which aligned with their genuine enthusiasm for the technology.
  • 🔄 The evolution of Next.js, particularly the introduction of server components and their asynchronous capabilities, represented a significant shift in the speaker's perspective, transforming them into a strong proponent of the framework.
  • 🚀 The speaker's passion for Next.js is rooted in their personal development journey and the evolution of the framework, rather than any financial incentives or sponsorships.

Q & A

  • What was the speaker's initial impression of functional programming when they first tried Elixir?

    -The speaker initially found functional programming with Elixir to be weird but quickly fell in love with it, to the point where they loved coding.

  • Why did the speaker dislike working with Go?

    -The speaker disliked working with Go because they had fallen deeply in love with functional programming and the thought of not doing it hurt, making them unproductive and unhappy.

  • How did the speaker's experience with React change their perspective on front-end development?

    -The speaker discovered the power of the component model in React and composition, which made them fall in love with front-end development quickly, despite previously hating writing JavaScript.

  • What was the speaker's role in the team that used Elixir at Twitch?

    -The speaker joined the team at Twitch without being a qualified developer but ended up contributing significantly, especially after moving from backend to frontend roles.

  • Why was the speaker frustrated with the API layer in their work at Twitch?

    -The speaker was frustrated because the back-and-forth with the backend team to get features shipped was time-consuming and often held up the shipping process, which was a difficult problem to solve.

  • What motivated the speaker to use Vercel Functions (API Routes) in their project?

    -The speaker was motivated to use Vercel Functions to avoid being blocked by the backend team and to have the ability to quickly add backend functionality to their frontend project without changing the framework.

  • Why did the speaker eventually choose to use Next.js for their video call app?

    -The speaker chose Next.js to bundle all the API endpoints into a single Lambda, which reduced build times and improved performance, as opposed to having each endpoint compiled and deployed individually.

  • What was the speaker's initial opinion on Next.js's data fetching methods?

    -The speaker initially disliked Next.js's data fetching methods, particularly getServerSideProps, because they found it to be inconsistent, not type-safe, and not providing the necessary functionality for their pages.

  • How did the introduction of Next.js's Server Components change the speaker's perspective on the framework?

    -The introduction of asynchronous Server Components made the speaker fall in love with Next.js, as it allowed for a more seamless and type-safe way to handle data within components, aligning with the speaker's vision for a better development experience.

  • What was the speaker's involvement with Vercel and Next.js before becoming a well-known advocate?

    -The speaker used Vercel and Next.js in their projects long before becoming a public advocate, and their positive experiences with the technologies led to them promoting them to others and eventually creating content about them.

  • How did the speaker's content creation journey begin, and what was the impact of their first few videos?

    -The speaker's content creation journey began with a live stream to showcase their stack to creators, which eventually led to a video that gained traction. Their first few videos, including a mock interview with Dan Abramov, helped establish their presence and credibility in the developer community.

Outlines

00:00

🌟 Journey to Next.js and Vercel Advocacy

The speaker shares their personal journey with Next.js and Vercel, starting as a Python developer at Twitch who transitioned into using Elixir and fell in love with functional programming. They discuss their dissatisfaction with the traditional back-end and front-end synchronization process and how their experience with Vercel functions, initially used for server-side code without affecting the main codebase, led them to become a strong advocate for the platform. The narrative highlights the evolution of their career and their transition from a back-end developer to a front-end enthusiast, all while emphasizing the importance of API layers in complex front-end applications.

05:00

🛠 Overcoming Backend Bottlenecks with Vercel Functions

The speaker recounts their frustration with slow backend deployments and how they leveraged Vercel functions to bypass these inefficiencies. They detail their initial use of Vercel functions, then known as the API directory, to create serverless endpoints that allowed them to deploy features faster without relying on the backend team. The speaker also discusses the challenges of local development with Vercel CLI and their efforts to streamline the process, ultimately leading to a more efficient workflow that integrated front-end and back-end functionalities within the same project.

10:02

🔄 Transitioning to Next.js for Improved Build Performance

The speaker describes the shift to Next.js as a solution to the growing build times and deployment issues they faced with Vercel functions. They explain how individual API files were compiled and deployed separately, leading to increased build times and inefficiencies. The adoption of Next.js allowed them to bundle all API endpoints into a single Lambda function, significantly reducing build times and improving performance. The speaker also touches on their initial dislike for Next.js features but acknowledges the framework's role in streamlining their development process.

15:03

📡 Embracing tRPC for Simplified Data Fetching

The speaker shares their experience with tRPC, a data fetching solution that greatly simplified their codebase and improved type safety. They discuss the transition from traditional API endpoints to using tRPC, which allowed for more efficient and streamlined data fetching within their application. The narrative highlights the reduction in code complexity and the ease of maintaining the application with tRPC, showcasing the benefits of this technology in their development workflow.

20:03

🚀 The T3 Stack and the Evolution of Development Practices

The speaker reflects on the rise of the T3 stack, which combines Next.js, tRPC, and other technologies, and its impact on their development practices. They recount their advocacy for using Next.js as a bundler and the community's reception of the T3 stack, leading to the creation of tools like `create-t3-app`. The speaker also shares their experience of engaging with companies behind the technologies they use and the excitement of contributing to the evolution of web development frameworks.

🌐 The Impact of Server Components and the Future of Next.js

The speaker discusses the introduction of Server Components in Next.js and its profound impact on their perspective of the framework. Initially skeptical, they were won over by the asynchronous nature of Server Components, which aligned with their vision for seamless data fetching and rendering in React components. The speaker shares their transition from a critic to a passionate advocate for Next.js and Server Components, highlighting the transformative potential of these technologies for the future of web development.

Mindmap

Keywords

💡Next.js

Next.js is a JavaScript framework for building user interfaces, particularly for server-rendered React applications. It is central to the video's theme as the creator discusses his journey from skepticism to becoming a 'fanboy' of Next.js. The creator describes how Next.js evolved from being a simple bundling tool to a framework that supports advanced features like Server Components, which he finds groundbreaking.

💡Server Components

Server Components are a feature in Next.js that allows developers to fetch data and perform server-side operations within a React component. The video emphasizes the creator's excitement about this feature, noting it as a game-changer that simplifies data fetching and reduces the complexity of server-client communication, as he mentions how it 'clicked' for him after trying it out.

💡API Layer

The API layer refers to the set of protocols and tools used to build software applications, defining how software components should interact. In the context of the video, the creator discusses the importance of a well-defined API layer for synchronizing backend and frontend development, highlighting how it was a significant part of his work at Twitch and influenced his appreciation for frameworks like Next.js.

💡Elixir

Elixir is a functional, concurrent, general-purpose programming language that runs on the Erlang VM. The creator mentions his initial experience with Elixir in 2017 as a turning point in his career, where he fell in love with functional programming, setting the stage for his later appreciation of other technologies and frameworks.

💡React

React is an open-source JavaScript library used for building user interfaces, maintained by Facebook and a community of individual developers and companies. The video describes the creator's initial dislike for front-end work and JavaScript, which changed dramatically when he started using React, appreciating its component model and leading to a reevaluation of his career path.

💡GraphQL

GraphQL is an open-source data query and manipulation language for APIs, and a runtime system for executing queries with existing data. The creator discusses his experience with GraphQL at Twitch, where it served as a contract between the front end and back end, allowing for efficient and synchronized development work.

💡TRPC

TRPC is a framework for building serverless APIs with TypeScript and React. The creator mentions TRPC as a solution that simplified his codebase and made maintaining server-client connections much easier, highlighting its role in his transition to a more streamlined development process.

💡Vercel

Vercel is a cloud platform for websites and web services that offers a global CDN, automatic HTTPS, and a unified workflow for developers. The video script discusses the creator's positive experiences with Vercel, particularly its ease of deployment and integration with Next.js, which contributed to his enthusiasm for the framework.

💡TypeScript

TypeScript is an open-source programming language that builds on JavaScript by adding static types. The creator's transition from various languages to TypeScript is noted in the script, framing it as a significant upgrade in his development experience, especially in conjunction with React and other modern tools.

💡Remix

Remix is a framework for building web applications, similar to Next.js but with a different approach to routing and architecture. The creator mentions Remix in the context of comparing the popularity of different frameworks, indicating the competitive landscape within the JavaScript ecosystem and the growing interest in modern development tools.

💡T3 Stack

T3 Stack refers to a combination of technologies including TypeScript, TRPC, and Next.js, which the creator advocates for building efficient and scalable web applications. The video describes the T3 Stack's rise in popularity, reflecting the creator's belief in its effectiveness and the community's adoption of the stack.

Highlights

Personal journey from a Python developer to a fan of functional programming and React.

Initial introduction to Elixir in 2017 and the subsequent shift in programming perspective.

The challenge of working with different languages and not feeling at home with any specific language.

Transition from backend to frontend and the realization of the importance of the API layer.

Experience with GraphQL as a contract between backend and frontend teams.

Frustration with the inefficiency of back-and-forth communication between front-end and back-end teams.

The decision to join a startup and the excitement to build mobile and web apps without constant blocks.

Choice of Expo and React Native for mobile app development to enable fast shipping of updates.

Discovery of Vercel Functions (formerly API Directory) and the benefits of serverless backend functionality.

The impact of Vercel's serverless functions on reducing build and deployment times.

Transition from using Netlify to Vercel for web deployment and the advantages it provided.

The introduction of Next.js to bundle API endpoints and improve build performance.

Adoption of tRPC to simplify code and improve type safety in data fetching.

The significance of server components in Next.js and their ability to handle data fetching asynchronously.

Personal advocacy for the T3 stack and its rise in popularity among developers.

The evolution of the speaker's YouTube channel and the shift in content creation strategy.

Engagement with Vercel and Next.js teams and the influence of server components on personal perspective.

Reflection on the journey from a backend developer to an advocate for modern frontend frameworks and tools.

Transcripts

play00:00

we talk a lot about nextjs on this

play00:01

channel how to use it how it works all

play00:03

the things you can do with it what we

play00:05

haven't talked about is why specifically

play00:07

why do I use next how did I get here in

play00:09

the first place what made me such a huge

play00:11

Fanboy of next and versell this video is

play00:13

explicitly not sponsored by versell I

play00:16

have a couple other sponsored videos

play00:17

with them coming up they have no idea

play00:18

making this one I'll be honest I didn't

play00:19

either until just now I'm filming this

play00:21

live on the Fly cuz we were talking

play00:22

about it I realized it was an

play00:23

interesting topic because my history

play00:25

with versell is nothing like people seem

play00:27

to think it goes back quite a bit in

play00:29

fact all the way back to 2017 when I

play00:32

first started using Elixir at twitch

play00:34

when I joined at twitch I was I guess a

play00:37

python Dev at best but honestly I wasn't

play00:39

much of a Dev at all I had written a

play00:41

bunch of plugins in Java for my

play00:42

Minecraft servers I somehow just barely

play00:44

managed to pass my data structures class

play00:46

in C++ and I was working on some things

play00:48

in Python for the research projects I

play00:50

was contributing to I even had been

play00:52

working on iOS apps and specifically

play00:53

Apple watch apps a bit at the time which

play00:55

were a massive Objective C and a tiny

play00:57

bit of Swift but honestly I didn't

play00:59

really feel at home with any specific

play01:00

language and barely even considered

play01:01

myself a programmer I only got into

play01:03

twitch because the person who ran the

play01:04

team had the same music taste as me and

play01:06

decided to offer me a 3-month contract

play01:08

despite not being qualified at all 6

play01:10

months later yes I got my contract

play01:12

extended because I wasn't doing well

play01:13

enough but at the six-month Mark I was

play01:15

doing well enough they decided to keep

play01:16

me fulltime and that team I had randomly

play01:18

joined this new team that formed was

play01:20

using Elixir despite the rest of the

play01:21

company using Ruby and a little bit of

play01:23

go I did not know what I was getting

play01:24

into when I tried Elixir which was my

play01:26

first real functional programming

play01:27

language and I fell in love fast it went

play01:30

from oh this is weird to wow I love code

play01:32

now so fast so fast that when a year

play01:36

later the team folded and I had to go

play01:37

write and goang I hated it I hated it so

play01:40

much I had fallen so deeply in love with

play01:42

functional programming that the thought

play01:44

of not doing that hurt it hurt so much

play01:46

that I just wasn't productive I was so

play01:48

unhappy that my manager pulled me aside

play01:50

to subtly let me know that I would have

play01:52

an issue if I didn't pick up my

play01:53

performance but also cuz he noticed how

play01:55

unhappy I was and that I wasn't enjoying

play01:57

my work he didn't mince words he made it

play01:59

very clear to me that I was not

play02:00

performing to the expected bar but also

play02:03

that he didn't think it was because of

play02:04

my lack of engineering capabilities just

play02:05

my lack of content using the tech I was

play02:07

using he pushed me to contribute to the

play02:09

rewrite of the twitch site moving us

play02:11

from Ember to react and I fell in love

play02:14

fast I did not expect to I was known as

play02:16

like the front-end hater guy I was

play02:17

shipping live view in 2017 with elixir

play02:20

in Phoenix because I hated writing

play02:22

JavaScript that much I was probably one

play02:23

of the first production users of live at

play02:25

the time when I started using react and

play02:27

I started playing with the composition

play02:28

seeing how powerful the component model

play02:30

was I fell in love fast I fell in love

play02:33

so fast that to this day I'm largely

play02:34

stereotyped as a front-end engineer

play02:36

which is really funny to me because I

play02:38

was a backend for the vast majority of

play02:40

my career and even today I'm spending

play02:41

more of my time thinking about servers

play02:43

than clients although the relationship

play02:45

between them is something I spend a lot

play02:46

of time on too so that's my history of

play02:48

how I got into react how do we end up

play02:50

here well after years of contributing at

play02:52

twitch be it the internal tools like the

play02:54

one we had for the safety stuff as well

play02:55

as the public facing twitch site I got

play02:58

to learn a lot about best practices for

play03:00

building and scaling complex front end

play03:02

applications one of the things I learned

play03:03

is the importance of the API layer that

play03:05

the front end is working with since I

play03:07

had been backend first and then I moved

play03:09

to front end I was actually in a really

play03:10

good position to talk with the backend

play03:12

teams to make things come together I

play03:14

spent most of my time talking with the

play03:16

teams running the back end and the

play03:17

graphql stuff that we were actually

play03:19

communicating with and using in our

play03:20

services in order to make sure our stuff

play03:22

shipped and worked as we expected that

play03:24

synchronization was essential and ended

play03:26

up being a huge portion of my time spent

play03:28

and honestly I love graphql this because

play03:30

it gave us a contract to put in the

play03:31

middle between the back end and the

play03:32

front end and once we agreed on it we

play03:34

could all go our separate ways and work

play03:36

and eventually come back together to

play03:37

make sure it all combines correctly and

play03:39

if it doesn't somebody got fired which

play03:40

was awesome okay we should have fired

play03:42

more people at that point but you get

play03:43

what I'm trying to say it was really

play03:45

cool having a solution that let us as

play03:47

back end and front end agree on

play03:49

something and then go do our thing the

play03:50

harsh reality was if the front end

play03:52

needed something and backend was too

play03:53

busy to do it either you did it yourself

play03:56

which ended up being a ton of work

play03:57

especially if you weren't working in

play03:58

that code based regular

play04:00

or you politely asked and waited until

play04:02

hopefully someone bothered to ship the

play04:04

thing that back and forth ended up being

play04:06

so much of the thing holding up shipping

play04:09

for us that it frustrated me to no end I

play04:12

got so tired of waiting in these back

play04:15

and forths that I ended up doing a lot

play04:17

of the backend work myself and then

play04:18

getting blocked in code review and yeah

play04:20

it was a mess things that should have

play04:22

taken a few hours to do ended up taking

play04:23

days if not weeks not because the

play04:25

process is slow or because big companies

play04:27

work that way simply because

play04:29

synchronizing the back end and the front

play04:30

end properly across teams across

play04:32

Technologies across code bases was a

play04:34

difficult problem eventually I left

play04:36

twitch to join a startup I joined the

play04:38

startup I took over client fully and I

play04:40

was really excited to build the mobile

play04:41

app and the web app specifically I was

play04:43

excited to not be blocked constantly and

play04:45

being able to ship updates whenever we

play04:47

had them so our users could have a great

play04:48

experience no matter what issues they

play04:50

ran into and that's why I picked Expo

play04:51

and react native so we could ship stuff

play04:53

really fast to mobile but web I didn't

play04:55

really have a go-to solution yet I was

play04:57

using netlify for my own personal stuff

play04:58

but I was having a few issues getting it

play05:00

to deploy specifically I was using snow

play05:02

pack not webpack for the faster build

play05:04

times and it was not doing great with

play05:06

NFI at the moment eventually I got it

play05:08

working but I've been hearing more and

play05:09

more about this forell thing what pushed

play05:11

me over the edge was very specific this

play05:13

backend team that used to be the front

play05:15

end team that didn't like me too much

play05:16

was taking forever to ship stuff I would

play05:19

request a change I would wait 12 hours

play05:20

for them to wake up they'd reply saying

play05:22

oh no it works fine the way it is look

play05:24

at our example I would wake up go check

play05:26

the example it didn't work I would tell

play05:28

them that wait another 12 hours to which

play05:30

they reply it totally works you're just

play05:31

holding it wrong and never once did it

play05:33

actually work the way they specified so

play05:35

I was constantly locked by these guys we

play05:37

had a few random things that we needed

play05:39

that they kept saying we're going to

play05:41

take days if not weeks to build that I

play05:43

knew shouldn't take that long so I need

play05:44

a way to run a little bit of serers side

play05:46

code that wouldn't get into their repo

play05:49

CU as soon as it touched their GitHub I

play05:51

had no ability to ship anything that

play05:53

involved this team blocked me immensely

play05:55

So eventually I convinced the CEO to let

play05:58

me spin up little small end points that

play06:00

weren't stateful which meant he said

play06:02

that they weren't backend his definition

play06:03

of backend was fully stateful including

play06:05

the database running constantly but I

play06:07

convinced him that I could run these

play06:09

oneoff functions somewhere just to fetch

play06:11

some data from a backend API and fix it

play06:13

for me and eventually he caved and said

play06:14

sure So I started hunting and when I

play06:16

started hunting I discovered something

play06:17

really cool and no it wasn't next a

play06:20

really cool thing I discovered was

play06:22

versel functions they've had a lot of

play06:23

different names over the time but when I

play06:25

was using this in 2021 they were still

play06:27

called the API directory no this didn't

play06:29

mean the API directory next it meant

play06:31

that you could just have a folder named

play06:33

API in your repo export a function and

play06:35

now it's an endpoint whatever you export

play06:37

here can now be used by versell to

play06:40

handle get post put whatever and when I

play06:42

realized I don't have to change my

play06:43

framework I don't have to change

play06:44

anything I can literally just make this

play06:47

folder in my frontend project named API

play06:49

put a file in it hello. TS and just do

play06:52

something there I was like oh this

play06:55

is an obvious solution so I made the

play06:57

move over and that move was awesome

play06:59

having access to full backend run times

play07:02

without having to think about the

play07:03

scaling or any of those things made it a

play07:05

very obvious choice for me so funny

play07:07

enough whether or not you believe it I

play07:08

was using versell years before I had

play07:11

ever touched next because I was still

play07:13

super snow pack pilled eventually moved

play07:15

over to vet but I kept my front and my

play07:17

back end separate still I just like the

play07:19

idea of them being in the same code base

play07:21

so I could make changes at once and have

play07:23

everything synchronized properly and

play07:24

having the ability to just add backend

play07:26

functionality to my frontend repo by

play07:28

adding one little file in the API

play07:30

directory was magic and if I go back to

play07:32

our old code API added let's take a look

play07:35

at

play07:36

this here is the code where I was

play07:38

handling all my off in my API helpers

play07:40

folder I was still using worker KV for

play07:43

all of my

play07:43

storage and it was a mess I like

play07:45

hardcoded the key just to like get it

play07:47

working add user to room call off you'll

play07:51

see I have all these API functions for

play07:53

the different things so get allowed user

play07:54

handle request this was before they had

play07:56

the get post put all of that this was

play07:58

just request response which were versel

play08:01

but they were pretty standard request

play08:02

response from like um the express

play08:04

request response but in here handle

play08:06

request room names with query make sure

play08:08

that it's a string throw we lowercase it

play08:11

get the value from KV if no perms we

play08:14

send a 403 otherwise we actually send

play08:16

you the content I'm almost positive that

play08:19

worker KV instance is dead and if not

play08:20

I'll go kill it right after yeah so as

play08:24

you see here pretty boring old V code I

play08:27

even added like a port call cuz I was I

play08:29

one of the Annoying Parts is in order to

play08:31

run this locally I had to have the API

play08:34

run through the versel CLI and the

play08:37

versel CLI is overall pretty good I

play08:39

honestly don't use it that much but for

play08:41

this it was nice cuz I could run these

play08:43

API directory things locally and have V

play08:45

running locally too the issue was V kept

play08:48

getting its requests eaten by the versel

play08:51

runner which was obnoxious I actually

play08:53

have um my blog part of why I made my

play08:56

blog originally was to about this

play08:59

using V on

play09:01

versel because I went to hell in back to

play09:04

fix weird things around like query pams

play09:06

that were being eaten because V doesn't

play09:08

format them correctly and like that

play09:10

and I wrote a whole guide on how to make

play09:11

this all come together so you could have

play09:13

your API directory work with v in local

play09:16

Dev it was annoying but I made it all

play09:18

work but then I ran into another

play09:20

unexpected issue when you put all of

play09:22

your routes in the API directory is

play09:24

individual files like this in order for

play09:26

them to compile and run safely each one

play09:28

gets compiled and deployed by itself so

play09:31

first off I was hitting limits of how

play09:32

many of those I could have and second

play09:34

off every new endpoint added like 40 to

play09:36

50 seconds of build time and deploy time

play09:39

which was entirely going against the

play09:41

thing I was trying to do which is make

play09:42

it as fast as possible to make changes

play09:44

and fix things so even though this code

play09:45

base was awesome I had my super client

play09:47

heavy stuff and I had my super server

play09:48

heavy stuff we even browse through the

play09:50

files and I'll show you that it was a

play09:52

pretty boring V app where I had my react

play09:55

query client provider which I was using

play09:57

for just fetching data I had my boring

play09:59

all pages which were settings home and

play10:02

call and call mostly was doing client

play10:04

side stuff because this was an app for

play10:06

doing video calls so obviously this

play10:07

one's going to be very client heavy I

play10:10

had all the different states if not in

play10:11

call return the join if PR's Channel

play10:14

return call not found if it's loading

play10:15

return loading if data if no token on

play10:17

off and then I actually render the video

play10:19

call but these types of things were

play10:23

pretty client heavy so I didn't see a

play10:25

need to use a serers side framework why

play10:27

would I ever need nextjs for my video

play10:30

call app the reason I needed it was

play10:32

because of those build times and the way

play10:34

it was deploying since all of those

play10:36

different end points had become their

play10:38

own like lambdas my build times at this

play10:41

point were horrible I wonder if I can

play10:43

see easily here I don't think that the

play10:45

has the history for but my build times

play10:47

doing this had gotten to like 5 to 6

play10:49

minutes when before they were like 20 to

play10:51

30 seconds so I wanted a way to easily

play10:53

bundle all of this into one end point

play10:56

and after doing a little bit of research

play10:58

I learned that nextjs just does that for

play11:00

you when we were in the docs before with

play11:03

the uh versell functions you'll see

play11:05

there is the next app next pages and

play11:06

other Frameworks I was doing the other

play11:08

framework solution which by the way also

play11:10

works with other languages I don't know

play11:11

if it says that here but there are uh

play11:13

you can use go python Ruby or Edge run

play11:16

times and there's ways to use PHP and

play11:17

on this too which is actually

play11:18

really cool you can deploy any of those

play11:20

through versal just by putting it in the

play11:22

API directory so these docs got killed

play11:24

for the old version that I was using but

play11:26

I bet I can even find the pr where I did

play11:28

this this is the pr where I actually

play11:30

moved us over to nextjs I got at our

play11:33

routing I moved over to file based

play11:35

everything I deleted all of these API

play11:37

helpers because I can move all of these

play11:39

to the API directory and next I didn't

play11:43

have to change too much I got to delete

play11:44

a decent bit of code but the win here

play11:47

was that all of these Source Pages

play11:49

things got bundled at once instead of

play11:52

being bundled independently and if I go

play11:53

look at the code base at this point in

play11:55

time this ended up being a pretty basic

play11:57

app we had our API directory that had

play12:00

all of the apis in it and rather than

play12:02

each of these having its own build

play12:03

process and going out to its own Lambda

play12:05

all of these things got bundled into a

play12:07

single end point that was hosted on one

play12:09

Lambda by forell so my build times went

play12:10

from like 5 to 6 minutes down to like

play12:12

two and the performance was a lot better

play12:14

too because the end points were more

play12:15

likely to be warm since all of them were

play12:17

running out of the same Lambda so this

play12:18

ended up being a massive win for

play12:20

performance even if the developer

play12:21

experience was slightly slower because

play12:23

it had to use webpack which I had been

play12:25

webpack free for years at that point so

play12:28

my desire for the next API directory was

play12:31

so great that I was willing to do things

play12:33

I didn't like such as use webpack and

play12:35

deal with their data fetching stuff and

play12:37

God did I hate versel data fetching get

play12:39

server side props quickly became the

play12:42

bane of my existence I hated this so

play12:45

much it's hard to put into words it just

play12:47

did not make any sense so much so that I

play12:49

wrote my second ever real blog post

play12:52

which was an inconsistent truth next in

play12:55

type safety because get server side

play12:57

props was not type safe it was not a

play12:59

good client experience it was barely

play13:00

even a functional server experience I

play13:02

have a lot of videos now where I

play13:03

complain all about get serers side props

play13:05

and how awful it was the honest truth is

play13:07

that most of next was stuff that I hated

play13:09

like the things that made next different

play13:11

from V or from other Solutions just

play13:14

pissed me off to no end I actually

play13:16

didn't like next at all what I did like

play13:19

was its ability to collocate my backend

play13:21

code and my front end code in one

play13:22

project in a meaningful way where the

play13:24

server and the client are much more

play13:26

closely tied even if the methods that

play13:28

they had provided for sharing things

play13:30

between the two were things that I hated

play13:32

and believe me I hated all of those

play13:34

things to the point where honestly more

play13:36

often than not I was just calling react

play13:38

query everywhere so if we find like any

play13:40

of the actual code which would be in

play13:42

Source components you'll see here I just

play13:44

have a bunch of use Query calls where I

play13:47

am fetching things from my server and I

play13:50

just do SL API now because I know where

play13:51

it's going to be which is nice and I

play13:53

have a bunch of these used query calls

play13:54

all over the code base where I'm doing a

play13:55

bunch of like parsing and making sure

play13:57

the data is the right format and

play13:59

but it was still better than server side

play14:01

stuff because get serers side props

play14:02

didn't really give me the stuff I needed

play14:04

for most of the pages especially because

play14:06

it had to be relay Dynamics it was for

play14:07

video calls next only gave you a

play14:09

solution for when the page first

play14:11

rendered from that point forward it was

play14:12

your problem and I hated that so I used

play14:16

almost none of next's server s side

play14:18

stuff for react I used the API directory

play14:20

to host apis but then I made another

play14:22

important change in September of 2021 I

play14:26

moved us to trpc which let me delete

play14:28

quite a bit of code and made maintaining

play14:30

all of this hilariously simpler yes this

play14:33

is when I actually got trpc pilled I

play14:35

played with it quickly for this project

play14:36

and almost instantly fell in love and

play14:38

realized I needed to be using it for

play14:39

like everything here's my Agora router

play14:42

Agora was the solution we were using for

play14:44

our web RTC at the time and it was way

play14:46

simpler I have my router which has my

play14:48

off context I have a query which has get

play14:50

token I have my input which is a room

play14:52

slug which is now validated this is all

play14:53

validated here so I could delete all the

play14:55

validation code and then I have my

play14:57

resolver which returns n if you don't

play14:59

have a session and then it Returns the

play15:00

Agora off token if you do same deal for

play15:02

getting the embed token all of this code

play15:04

became hilariously simple to write and

play15:07

then actually using it was even simpler

play15:09

trpc usequery give it the string give it

play15:11

the values and it's all not just working

play15:13

but type safe I was able to make so

play15:16

much simpler if we look for the used

play15:17

call token code I deleted yeah see how

play15:19

much longer these endpoints were with

play15:21

all of the checks making sure it's a

play15:22

post making sure that we have the right

play15:24

data getting the session making sure we

play15:25

have a user ID getting their profile

play15:27

making sure we have the right data and

play15:29

then finally doing the thing we were

play15:30

here to do this went from 41 lines of

play15:33

code to like five and consuming it was

play15:35

so much easier too like hilariously so

play15:39

and I was able to delete all of these

play15:41

giant end points in favor of things that

play15:42

are way easier to work with oh here's

play15:43

the call token code so this 33 line get

play15:47

call token I could just delete entirely

play15:50

where is the actual use for it though

play15:53

okay can't find where I deleted the call

play15:54

token code but I'm sure it's in there

play15:56

somewhere regardless you get the point I

play15:58

was not using next the way you probably

play16:00

think of nextjs because I wasn't using

play16:02

next the server and client all-in-one

play16:04

solution in fact I was barely using next

play16:06

beyond the bundler I found it as a

play16:08

really convenient way to put my react

play16:10

client code and my whatever else server

play16:12

code in the same project all at once and

play16:15

as we all know from the original T3

play16:16

stack it was actually a good experience

play16:18

I had massively advocated for this idea

play16:20

of using next as a way to make a good

play16:21

client and a good server that are close

play16:24

but not tied and using things like trpc

play16:26

to do that gluing part together at this

play16:28

point I was really liking my experience

play16:30

with next in versell even if I wasn't

play16:32

using next I had gone all in on versell

play16:34

and the way it let me build and deploy

play16:36

my Solutions so much so that some of my

play16:38

co-workers from both ping and other

play16:39

startups like rose here call it out to

play16:41

this day cuz I was far from YouTube this

play16:43

was years before I had started YouTube I

play16:45

was just trying to build as effectively

play16:47

as possible and Rose ended up being one

play16:48

of the first people I converted to using

play16:50

versell it was weird cuz now there's

play16:52

literally probably hundreds of thousands

play16:54

of y'all but at the time I didn't have

play16:56

influence I had like 50 followers on

play16:57

Twitter and a few nerdy friends so I

play16:59

just talked about this with them and

play17:01

they fell in love too and I love Rose

play17:03

for calling this out here because yeah I

play17:05

was obsessed once I realized how much

play17:06

easier all of these things could be

play17:08

after spending a decade suffering

play17:09

through all of these parts the ability

play17:11

to link a project from GitHub that would

play17:13

serve all of my apis and all of my

play17:15

clients the best possible version of my

play17:17

experience by clicking two buttons to

play17:19

link my GitHub to my versel project was

play17:22

magic and I yes I fell in love I sounded

play17:25

a lot like a shell because it was unlike

play17:26

anything I'd experienced before but it

play17:28

was genu as Rose says here I actually

play17:31

really love this stuff so much

play17:32

so that when I got into white combinator

play17:34

I was just seeking people to nerd out

play17:36

about this with and I couldn't find them

play17:38

I was desperately looking for people who

play17:39

wanted to talk about these things with

play17:41

me because I just was such a nerd so

play17:43

that's why I did the video that many of

play17:45

y'all have probably seen the roundest

play17:47

video this is the video this was my

play17:49

first Dev video and it also wasn't a

play17:52

video it was me doing a quick live

play17:54

stream because I was building tools for

play17:55

creators and I wanted to better

play17:56

understand what they needed and I'd been

play17:58

talking to a few people people on

play17:59

Twitter who I wanted to explain my stack

play18:00

to that didn't seem to get it so I made

play18:03

this to Showcase why I like this text so

play18:05

much I posted it on YouTube didn't

play18:07

really do much but then I got lucky

play18:08

enough to have Dan abramov come on for a

play18:10

mock interview which did really well and

play18:12

eventually got this to kick up too to

play18:13

the point where both of these videos

play18:15

ended up being pretty close in terms of

play18:16

viewership long term which is kind of

play18:18

crazy to think that a brand new YouTuber

play18:20

was able to get as many views on his

play18:22

building a video app live as he was

play18:25

interviewing Dan abramov just

play18:27

mind-blowing the reason I was able to

play18:28

have Dan on is I care a lot about how

play18:29

job interviews work so when he said on

play18:32

Twitter he was going to be doing some

play18:33

mock job interviews with YouTubers if

play18:34

anyone was down to hit him up I

play18:36

obviously immediately hit him up he was

play18:37

down I got to do that it was one of the

play18:39

first pieces of content using ping

play18:40

because I had to have him call in really

play18:42

proud of that really proud of that

play18:43

interview yeah they these were the first

play18:45

two ever I learned so much from doing

play18:47

that more importantly I got hooked on

play18:50

having these deep technical

play18:51

conversations and sharing the magic of

play18:53

how these tools were coming together the

play18:55

beauty of combining next as like a

play18:57

bundler effectively

play18:59

with react a wonderful client side

play19:01

framework with trpc the best way at the

play19:03

time to connect your server and your

play19:04

client together and Prisma which was

play19:07

honestly kind of magical at the time

play19:08

because there was no good typescript orm

play19:10

that had that level of type safety built

play19:12

in Planet scale which broke my brain at

play19:14

the time oh Planet skill was so cool and

play19:17

Tailwind because I finally liked styling

play19:19

having all of this come together in a

play19:21

way that felt that good was magical and

play19:23

even 2 years later I almost missed that

play19:25

moment but the magic wasn't something

play19:27

only I was feeling because T3 stack took

play19:29

off there were points where create T3

play19:31

app which was made by nexil a fan of

play19:32

mine soon after all of this create T3

play19:34

app was getting more invocations than

play19:35

remix which is crazy when you think

play19:37

about it that a YouTuber's fans built a

play19:39

boiler plate using their recommended

play19:41

technologies that became the third most

play19:43

popular framework for react but that's

play19:45

how cool this stuff was to use and funny

play19:47

enough as I've been hinting at this

play19:48

whole time most of it was built around

play19:49

avoiding next to the best of your

play19:51

ability next was the the box that this

play19:53

all went in but we had basically dumped

play19:56

the box out shook everything out of it

play19:58

put back like two parts and then filled

play19:59

the rest with other things and it was

play20:01

awesome it was so awesome that I was

play20:03

starting to talk to versel themselves

play20:04

and the people who worked on next which

play20:06

was mind blowings I was just a fan at

play20:07

the time all of a sudden I get to

play20:09

actually talk about and work with these

play20:10

people and then the channel blew up like

play20:12

really quickly I only started posting

play20:14

videos for real in April of 2022 I had

play20:17

done like one or two before then but it

play20:18

wasn't something I was taking very

play20:19

seriously and then I started doing

play20:21

videos with prime then I started posting

play20:22

more often and it blew up fast and I was

play20:24

blown away and I realized quickly we had

play20:27

to change how the channel ran cuz I had

play20:28

to have an editor helping I had to have

play20:30

others helping me research topics and

play20:32

manage the channel and I also had to run

play20:33

my company so expenses were going up and

play20:35

my time was going down I also had my

play20:37

first ever company reach out to talk

play20:38

about a potential sponsor which was up

play20:40

stash I also realized at the time I need

play20:42

up stash for a bunch of stuff so I tried

play20:43

it I loved it especially the rate

play20:45

limiter and I did my first ever sponsor

play20:47

deal which was a huge huge deal for me

play20:49

the idea of making money off of YouTube

play20:51

was just mind-blowing at this point I

play20:53

realized that sponsors were a thing I

play20:55

could do and as long as I picked ones

play20:56

that built things I trusted this was a

play20:58

really good opportunity so I reached out

play21:00

to all the companies I was shipping in

play21:01

production including Planet scale

play21:03

including axium including versel and

play21:05

they were all down so I ended up for the

play21:07

first time ever having a set of sponsors

play21:09

making this content possible not too

play21:11

long after that versell announces the

play21:13

app router and server components and my

play21:15

mind is blown initially I'm actually

play21:17

quite skeptical you could find my old

play21:19

videos where I first talk about nextjs

play21:20

and server components and my responses

play21:23

yeah I'm not sure but then they made one

play21:25

really big change that entirely shifted

play21:27

my tone they made server components asnc

play21:29

like properly asyn like you could just

play21:31

await a call there's even a clip from

play21:32

one of my old videos where I say they

play21:34

should have done this this is the future

play21:36

I dream of and this can absolutely

play21:38

happen like but the the point I wanted

play21:41

to make here is I dream of a world where

play21:43

for Server components you can define a

play21:45

component async do whatever in here and

play21:49

return yeah I was skeptical but then

play21:51

they changed it to be async and I

play21:53

decided to play and boy boy oh boy did I

play21:56

fall in love remember how before I said

play21:57

that I B Bally dumped out Hall of next

play22:00

in favor of my own Solutions I had been

play22:02

leap frogged many of the things I was

play22:04

putting my time and effort into suddenly

play22:06

felt both archaic and worse to use as a

play22:08

user when I saw how powerful it was just

play22:10

awaiting some data inside of your

play22:12

components I knew it was going to be

play22:13

magical not because I just saw it and it

play22:15

was obvious because I had put a bunch of

play22:17

time into Astro as well and the magic of

play22:19

just awaiting some data and having it

play22:21

type safe to just us in your markup

play22:23

without having to make an API endpoint

play22:24

or handle the types between the back end

play22:25

and the front end and all of this chaos

play22:27

just vanished and I realized this was

play22:29

the ultimate version of what I'd been

play22:30

seeking this whole time where v0 was

play22:33

endpoints in some other code base client

play22:36

code has to guess what data it's going

play22:38

to be getting to V1 of now the API

play22:42

endpoints are in the same code base to

play22:43

the thing I skipped the V2 of what if

play22:46

the get server side props Returns the

play22:47

data directly so that was just a mess

play22:49

and I stuck to like a V1 Plus+ of trpc

play22:52

doing the bridge instead but now this

play22:54

third generation of these Solutions of

play22:56

what if the components could actually do

play22:58

the server side stuff themselves and

play22:59

just pass the data down like properties

play23:01

and when it clicked it clicked hard it

play23:03

clicked so hard that I got called a

play23:04

fanboy and specifically I got called a

play23:06

shill a lot as though versell paid me to

play23:08

have these opinions despite the fact

play23:10

that when versel and I first Inked our

play23:11

deal which by the way the numbers have

play23:13

not changed since we started despite me

play23:15

being five times larger I could

play23:16

reasonably charge them more but I don't

play23:18

because I don't want to I'm very happy

play23:20

with the current terms of our deal

play23:21

things are working out great for

play23:22

everyone involved the magic of server

play23:24

components blew me the away and I

play23:27

went from unsure to one of the biggest

play23:29

Advocates very quickly seemingly too

play23:31

quickly because to this day I still get

play23:33

that verell paid me to believe

play23:35

these things that I didn't believe in

play23:36

the past but really what had happened

play23:38

was I used it in my perspective shift

play23:40

and that's why I made this video because

play23:41

I honestly think if you guys knew my

play23:43

history of going from a disgruntled

play23:44

backend Dev to a functional Fanboy to

play23:47

the guy porting twitch from Ember to

play23:49

typescript all the way to where I am now

play23:51

I think it makes a lot of sense why I

play23:52

feel the way I feel none of this has

play23:54

anything to do with what I've been paid

play23:55

I included those details because I think

play23:57

you guys should know them my perspec

play23:58

effective has not been influenced by the

play24:00

money that has been spent on my channel

play24:01

I love next because I went from not

play24:03

caring about next to not liking most of

play24:05

next to feeling like this is the

play24:07

framework of the future and when I

play24:08

started using next it was barely even

play24:10

the framework of the past it was such a

play24:12

mess and what the teams created here is

play24:13

something truly groundbreaking that I

play24:15

actually really love so yeah let me know

play24:18

in the comments about how I'm clearly a

play24:20

paig shill cuz it's what you guys love

play24:21

to do until next time maybe we'll have

play24:23

some opportunities to go ship some next

play24:25

anyways peace nerds

Rate This

5.0 / 5 (0 votes)

関連タグ
Next.jsServer ComponentsReactAPI EndpointsDevelopment HistoryFunctional ProgrammingElixirTypeScriptWeb DevelopmentTech Advocacy
英語で要約が必要ですか?