Freelance developer - React Query maintainer - Occasional OSS contributor - Been putting React on servers for a decade - Father of two - Homebrewer

Stockholm
Fredrik Höglund retweeted
Listen to me talk about @RedwoodJS and React Server Components compressed.fm/episode/176
4
6
520
Now you can start a prefetch in a Server Component without having to await the data. Let that sink in.. So impressed by the quick turnaround by @TkDodo on this feature.
The release with the wibbly wobbly promise-y stuff is here 🚀 github.com/TanStack/query/re…
1
1
11
1,077
The incredible thing about this and the swr@beta doesn't happen on first page load, but on page transitions. Because a promise is dehydrated, the RSC wont block the page transition on data, so if that data is already available client side, we wont suspend. Best of both worlds?
Okay I'm done. We can now start prefetching in server components without awaiting them, send the promises to the client and pick them up with useSuspenseQuery. That's pretty sexy. github.com/TanStack/query/pu…
1
14
2,315
We might still suspend on code etc, and there is still a roundtrip to the server involved, but in the right circumstances page transitions can happen quicker than before. The data in the client side cache is actually useful again for speeding up page transitions.
4
178
Fredrik Höglund retweeted
okay I got it. Have a look at this example here: github.com/TanStack/query/pu… no await on the `prefetch`. Only thing is that you have to specify that you want pending queries to be dehydrated as well, which I'm doing globally here: github.com/TanStack/query/pu… thoughts on that API?
3
1
8
1,944
Fredrik Höglund retweeted
What if an LLM could generate an RSC Payload that could be directly rendered by React? I had to find out. Introducing V -1 ✨
6
15
147
36,252
Fredrik Höglund retweeted
🔮 The official @tan_stack query course will go live next week, but you can check out the free course preview today: Head over to ui.dev/c/query, enjoy the first lesson (with video) and do some challenges and quizzes 🚀
2
9
123
9,718
Fredrik Höglund retweeted
React Compiler is officially open-source! Check out the code: github.com/facebook/react/tr… And learn more at fb.me/react-compiler
13
154
681
112,408
Fredrik Höglund retweeted
We just published the first beta for React 19! This beta release is for collecting feedback and preparing libraries for the next major version of React. To see what's included, check out the release post: react.dev/blog/2024/04/25/re…
64
766
2,997
839,418
Fredrik Höglund retweeted
So, @vercel reverted all edge rendering back to Node.js 😬 Wanted to correct the record here as it's something I've advocated for in the past, and share what I've learned since then. Also, the "edge" naming has been a bit confusing, so let's clear that up here as well. What is edge, anyway? We have too many products with Edge 😅 First off, Vercel has an Edge Network. A request comes in for your site. The edge region can go grab some HTML or JS for your site and quickly return it. Great. Then, sometimes, you have routing rules. When that request comes in, redirect it, proxy it somewhere else, or add headers before continuing (e.g. Middleware). You don't need to go all the way back to the origin. This is also great. Sometimes those routing or configuration rules need to be read from a file. We have "Edge Config" which is like reading from a JSON file in every region. Again, still good. Now, what about rendering my application with edge compute? Not as great. But Lee, you said... Yeah, I gotta admit, this one fooled me. It sounded great at the start – running close to the visitor makes sense. If I constrain my site to use this limited runtime, and make the tradeoff for access to the Node.js package ecosystem, I can (hypothetically) get better performance. This hasn't worked for two reasons. First, and most obvious, is that your compute needs to be close to your database. Most data is not globally replicated. So running compute in many regions, which all connect to a us-east database, made no sense. I believe many folks understood this. But then, maybe this limited runtime was better even if I only run it close to my database? Well, that was wrong too. We tested it extensively with @v0. Using the Node.js runtime with 1 vCPU (our "Standard" performance) option for Vercel Functions had faster startups 🤯 Are there other reasons for edge rendering? If Node.js functions can be faster, especially with Node v20, what about cost? I expected an edge compute pricing model, which is based on only paying for when your compute runs (and never I/O), would always be cheaper. Turns out that was also wrong. It can be cheaper sometimes! But not for all workloads, so some nuance applied here. Same story for security. I wanted edge compute to work, but customers kept telling me they wanted a private connection to other services (i.e. Vercel Secure Compute), or had concerns (or no interest) in doing global data replication (e.g. data sovereignty). So now what? It's a good lesson for me to be careful with naming / nuance going forward. Also, networks have gotten really fast. We saw with @v0 that it was faster to do SSR + streaming with Node.js than edge rendering. Now we're running @v0 with Partial Prerendering to see if this is better or worse (it's still experimental). The summary of PPR is: user makes a request, the edge region starts streaming back the HTML for the fast initial visual, and then your compute still runs in us-east or wherever close to your data. So far this has been about 50% faster time to first byte than SSR + streaming. Pretty amazing. I'll be sharing more on Vercel Functions improvements soon, as well 🦀
107
198
1,773
1,017,605
Fredrik Höglund retweeted
🔮 Exciting news: I'm so happy to announce that the course on TanStack Query I've been working on will launch May 22 🚀 Huge thanks to @tylermcginnis and the team behind @uidotdev for working with me on this 🙏
10
37
459
71,626
🤯 const [state, dispatch] = useReducer(…) useEffect(() => { if (state.effect) { const effect = state.effect delete state.effect return effect() } }, [state])
2
1
27
9,498
The plot thickens.
We should document the pattern, sure, but the safe version of the pattern is to use a ref for the effect. Deleting the effect property on state breaks the rules.
1
2
859
I’ve wondered for a while what the idiomatic solution to this looks like, it’s such a powerful pattern but always seemed hard to me to implement correctly, without breaking any rules. Almost wish for it to be built in.
3
542
Fredrik Höglund retweeted
We’re excited to share that React Compiler is no longer a research project: the compiler now powers instagram web in production and we’re working to ship the compiler across additional surfaces at Meta and prepare the first open source release.
2
72
563
98,470
Fredrik Höglund retweeted
PSA: If you've been using one of the experimental packages for Next.js App Router support with Apollo Client, urql or React Query, please update that dependency ASAP. All three were vulnerable for an XSS attack, and all three packages just published a new version with a fix.
2
13
28
9,362
Fredrik Höglund retweeted
Nice talk on migrating to RSC by @ephemjs btw not going down that route atm, but interesting insights & TIL in Next.js you can /pages and /app dir at the same time which is great for migrating step by step. That's really useful portal.gitnation.org/content…
1
2
14
937
Watch the recording of a panel discussion with top React experts such as @dan_abramov, @acemarke, @alessbell, @ephemjs, and @mweststrate. They discussed Open Source & "perceived competition" between projects. portal.gitnation.org/content…
4
13
3,034