๐Ÿ‘‹ I'm Alex & I tweet about web dev stuff Creator of @trpcio, work @square, scout @a16z

Malmรถ, Sweden
Been an amazing week ๐Ÿคฉ met so many amazing people who I only knew by tweets and commits previously Thanks @vercel for a great conference yday and for sponsoring @trpcio with an amount that perfectly covered my flights over โ™ฅ๏ธ
6
1
87
5,409
& thanks to @ballingt for letting me crash in his flat all week โ™ฅ๏ธ
7
1,023
Alex / KATT ๐Ÿฑ retweeted
Replying to @trpcio
@trpcio as a data access layer has been awesome as we scale the new PayPal checkout repo. It would have been much messier and less idiomatic to invent our own patterns and thus harder to scale to 90+ devs so quickly, and it allowed us to hedge against server action growing pains
3
17
2,680
Yo SF ๐Ÿ‡บ๐Ÿ‡ธ๐Ÿ‘‹
16
1,841
I'll just watch all of @t3dotgg's videos about it once it's over instead ๐Ÿซก
4
1
102
7,029
Alex / KATT ๐Ÿฑ retweeted
Can the Open Source Pledge actually fix open source? New video just went live talking all about it
2
9
92
16,978
I'll be in SF for a week from next Friday! Who should I meet? โœˆ๏ธ Anyone who wants to have an office buddy for a day and/or have a sofa that hasn't been slept on for way too long? ๐Ÿ˜…
9
12
3,768
I'm still trying to understand, could someone please explain how prevState is needed as a React-primitive to solve this problem nicely? To me this could be solved app-side by: A) a hidden input with the state at the point of clicking the submit-button (should allow same behavior as prevState?) B) preventing double submits on forms in onSubmit or by disabling the submit-button, potentially with a idempotency key as a hidden input if I wanted to be fancy I haven't experienced the problem being solved here at the scale of Facebook so maybe I've been solving it wrongly all my life? I've yet to see an example that makes this click for me
Have you click submit many times in a row and tested if itโ€™s handled correctly?
1
1
12
3,593
Has anyone found a use case for the `currentState`-argument in server actions yet? ๐Ÿ™ƒ
Can anyone show me a use case of the `currentState`-argument in a server action when using `useFormState()`? I struggle to see why it exists.
9
3
50
22,075
to me, anything you'd use it for is better done by a hidden input, see
Replying to @alexdotjs
- ๐Ÿซฃ AFAICT, you can't trust the value here and it needs to be validated alongside `formData` - ๐ŸŒ€ It needs to be the same type as the return type of the action, which makes inference circular - ๐Ÿšฉ the React docs need a troubleshooting section to explain it's there (react.dev/reference/react-doโ€ฆ), it should be a red flag that the API could be tweaked - ๐Ÿงฉ The arguments change depending on how you call it. This sorta goes against the "React way of thinking" that things are an independent "lego piece" that you can drop anywhere - ๐ŸŸ The state in `useFormState(action, initialState)` gets serialized and passed between server<->client which to me just adds unnecessary payload - โ„น๏ธ If you need to pass additional context with form data, you can add a `<input type="hidden" />`, I don't see why React needs to provide this
3
2,603
this looks pretty damn awesome
introducing one. not two.
3
2
11
3,091
This is how the commit history of a senior engineer looks like
Replying to @TkDodo
10x dev right there
9
2
82
7,428
Alex / KATT ๐Ÿฑ retweeted
Whatโ€™s new in @tan_stack React Query v5.59.0 youโ€™re asking? ๐ŸŽ‰ experimental support for use() in React ๐ŸŽ‰ const { promise } = useQuery(...) const data = use(promise) - can be used conditionally - integrated with React 19 and suspense - creates and caches a stable promise that resolves when data comes in or rejects github.com/TanStack/query/reโ€ฆ Give your thanks to @alexdotjs for contributing this. Just note that the feature is experimental, and you need to opt in by setting `experimental_prefetchInRender: true` on either your query or globally. Please try it out and give feedback ๐Ÿš€
10
39
492
60,109
Alex / KATT ๐Ÿฑ retweeted
I built an app that will fork a GitHub repo for you, and push commits directly to your fork replacing text to rename it in every file. No more laborious find and replace just to get into the next YC batch: forkme.mmkal.com
118
168
4,147
256,241
This *almost* worked ๐Ÿ˜‚ appreciate @ryanmagoon for looking into it ๐Ÿ™
Replying to @alexdotjs
hey @ryanmagoon, can PayPal sponsor my trip?
2
13
4,186
hey @vercel, I couldn't come last year when I was offered a ticket from y'all, is the offer still open for this year? ๐Ÿ˜‡ Would save me a bit on a trip that will already cost a bunch
3
8
1,305
Middlewares in tRPC ๐Ÿ“— Base procedures Most apps should only have a few base procedures that cover 99% of the app's use cases - In the below example, I have: 1. A public base procedure with logging 2. An authed base procedure that extends ^ 3. An organization procedure that extends ^ Playground example ๐Ÿ‘‰: tsplay.dev/mA6KQW See the router definition at the end, but some notable things below (you can open the link and step through the `^?`-comments) - The procedure builders can be chained which enables code reuse and makes it easy to do eg an `authedProcedure` you can add multiple `.input()`s in the same chain which enables "half-way" checks in the pipe (see orgProcedure('post.create')) - You can use the result of `next()` in a middleware which e.g. enables logging of the duration etc - Any middleware can override properties on the `ctx` - The .query() / .mutation() finalizes the builder and returns a clean query or mutation (hover `appRouter.addPost` at the very end) - .input() / .output() supports a wide set of different parsers automatically (zod, arktype, typeschema, etc) Standalone / `.concat()` middlewares Both of the above mainly exist with libraries in mind. `.concat()` merges to procedure builders as long as they're compatible We deprecated standalone middlewares in favor of `.concat()` as we think it covers all intents of purposes of standalone middlewares
tRPC question: What's the point of having t.middleware when there's t.procedure.use?
4
55
6,863
How cursed would it be to allow plugins of a library through by encouraging people to use `declare module`-style overrides? Playing with the idea to break out parts of trpc's procedure builder / middleware thing to its own package, but it's hard to make extendable w/o it
5
7
3,729
(I'm think what I really want here is higher kinded types)
1
1
964