Why do
@nextjs
server actions run sequentially, instead of just cancelling each other?
Video shows 2 examples (simulated slow network):
1. Next: actions run in sequence, UI updates after all requests are complete
2. Remix: actions cancel each other, UI updates after 1 request
Some progress on my GitHub clone with
@nextjs
app router :
- Created my 1st "full stack component" : <Markdown>
- Optimized my SQL queries from 800ms to 6ms
Let's go 1/13
#buildinginpublic
Next js just published a new canary version allowing to handle progressively enhanced form errors 🥳 :
Now i can say safely that next is really stable as this completes the full API for data fetching + mutations.
Here is a demo of how it works :
Some progress on the github clone with next App Router
- Started implementing the github action list component, which renders a modal on mobile
- For now you can filter by name, but against fake data (we will get the data later)
#buildinpublic
Some progress on my GitHub clone with
@nextjs
app router :
- Hacked a cache component in my app with the help of @/lubieowoce
- Using turbopack for dev now
- Christmas decorations 🥳 inspired by
1/19
#buildinginpublic
@vercel
announced
@nextjs
13, and their tagline was : "dynamic at the speed of static", so i wanted to test myself to see if it holds true.
By comparing a real next v13 app vs the
@astrodotbuild
website, and the result might suprise you :
👇
Week-end toy project : recreating the react router tutorial app, but with
@nextjs
app router.
Using all the cool features :
- edge runtime for absolute incredible perf
- server actions with progressive enhancement
- unstable_cache to not do unnecessary fetches
@webdevcody
@nextjs
This is why I always modify the default fetch cache in the root layout, to be either `default-cache` or `default-no-store`. This setting is propagated down to every page in app router, the 2nd value forces you to specify every fetch that you want to cache
Been using
@nextjs
app directory with
@tRPCio
and it is just a match made in heaven 🤩.
tRPC blurs BE and FE lines while app directory give me incredible DX with nested layouts 😍.
Some progress on my GitHub clone with next app router :
PREVIEW ENVIRONMENTS kinda like vercel in a self hosted VPS setup.
How does it work ?
Let’s dive in…
1/17
react `cache` primitive now works in client components. Fetching in client components is now way easier.
Right now it does not have many niceties of libs like react-query, but i think this could be something that is used under the hood, and write something like the 2nd picture
@trunarla
Right ?
For me School introduced me to some concepts I wouldn’t have known if I didn’t look (things like networking, how the OS works, etc) but most of the things I use daily I learnt them by myself on side projects.
I am once again asking you to just buy a VPS for 5$ a month, you can host as many DBs as you like and even host your entire startup in it.
Scaling, you ask ? you don't need to think about it, we both know you don't have any users 😛
@TheJackForge
Relatable, but for me it’s because of 3 reasons :
1- I’m an introvert and I prefer a job that doesn’t require many social interactions
2- I like highly focused activities that helps me forget everything around me
3- money 🤑
Things holding me back from using
@remix_run
:
- no SSG
- no 1st party image optimization
- no 1st party font optimization
- Cannot add <link rel="canonical" href="<url>" /> for SEO (seriously why ?)
⁻ ᵗʰᵉ ᵈʳᵃᵐᵃ
These two weeks have been very productive on the progresssion on my github clone with
@nextjs
app router :
- swapped pnpm for
@bunjavascript
- The search feature is completely finished and now works with a snapshot of 100+ of the most commented issues of 2023 in the nextjs repo
One of my biggest pain points about nextjs caching has finally been recognized and a new proposal to fix it has been made.
It will take time to implement it, but I’m just happy this is on the roadmap and has not been dismissed. 😌🙏
@puruvjdev
To do calculations (with money) it is better not to deal with decimals, and rather multiply by 100 for money to make calculations in cents.
You can convert later to dollars by dividing by 100
They say
@nextjs
app router is stable, but there are still weird bugs with parallel and interception routes, should we consider them as experimental or alpha like server actions ?
@pilcrowonpaper
If most of your routes are protected, repeating it everywhere is annoying and prone to human error, that’s why you use middleware.
Also middleware can also be applied on a route basis or to a group of routes.
Everyone : bun is totally gonna replace node
Me : bun —bun run dev
> Attempt to export a nullable value for "TextDecoderStream"
Me : 😕
Me : *continue using node anyway*
Ok after reading this, I am more convinced about why the
@reactjs
team pushes towards frameworks. Big fat client apps can become just unbearably slow because of the code size, and achieving good code splitting can be hard.
In tanstack query, is there a way to limit the number of queries that can run at any time globally ?
Like If i have an app that can potentially make a 1000 of requests but I want only 100 of them to run in parallel while the other wait showing a isFetching/isLoading to the dev.
I did not think about it, but it is a really cool idea to use Astro to build a SPA and if you want some static pages (for your blog or landing page for ex) just put it there.
Bonus with this : no need for a server, everything could be statically hosted !
Pretty cool stuff !
Hello
#twitter
, aujourd'hui après plusieurs mois de code in the dark, je vous présente kiss-cam, un outil qui permet aux créateurs de pouvoir passer des appels avec des invités pour des vidéos, interviews et shows en live
Le lien pour y accéder👉
Ok server actions are cool, progressively enhanced and all, but I don’t see anyone talking about validation.
The recommended way seems to throw an error, but this blows up the rendering instead.
Validation is a necessity in form handling or not ?
The `action` prop in forms in React canary is so damn convenient, so much unnecessary code removed, and I don’t even use server actions (just a Vite client-only SPA).
I will surely use the hell out of form hooks in my code, useFormStatus, useFormState, useOptimistic.
@alexsoyes
Déjà testé, mais ça bouffe trop de ressources sur ma machine, j’ai jamais pu à faire tourner responsively, Firefox/chrome et VSCode en même temps
Let’s face it,
@solid_js
and
@reactjs
are two totally different framework/libs with totally different mental models.
The only common thing they have is that they use JSX.
You can’t expect to transition from one to another without rewriting your mental model 1/n
Also reminder that this project is open source, if you tested the app and stumbled upon bugs, please open issues in the repo, I will make sure to resolve them as fast as possible.
Also, if you’d like to contribute to the repo, I’ve made issues for it :
These two weeks have been very productive on the progresssion on my github clone with
@nextjs
app router :
- swapped pnpm for
@bunjavascript
- The search feature is completely finished and now works with a snapshot of 100+ of the most commented issues of 2023 in the nextjs repo
Was all in on
@prisma
before but after watching
@ThePrimeagen
&
@MelkeyDev
stream on how many layers it runs, i am now friends with drizzle.
(Maybe until another one comes and steal my heart 😅)
@cramforce
If their usage is not to be primary used within forms, then make their default behavior to be ran in parallel instead of sequentially 😕, most client-server communication within apps aren't blocking especially in an app like twitter that is very responsive.
This week's progress on the github clone with next app router :
- I changed the design of the search input to better highlight the current search tokens
- i also removed the auto submit on search, now you have to manually confirm your input before submitting
#buildinpublic
@buildsghost
I recommend it has more than 1000+ icons coming in multiple styles and with different FW adapters (vue, react, etc), you can also copy directly the SVG from the site.
I use it intensively on my apps
Upgraded this example with the latest next canary and now i can just return JSX for the popup inside an action. This is pretty cool for implementing patterns like twitter & github hovercards.
Bonus point : no extra JS shipped for the component
Made a little experiment today with next : i wanted to see how easy it was to implement a twitter hover card without any api.
turn out it was really easy, bonus point i used the same component for the client & the server for the pokemon detail
link :
WoW tldraw blew my mind by actually being usable on mobile without too much pain 🤯.
A testament to caring about user experience even for the users you don’t expect to use your app regularly.
Today i've seen something exciting coming to the
@reactjs
website 👀
I'm not going to disclose the URL but if you search in the reactjs docs repo you could find it
So what are you waiting ? Go try
@nextjs
13 today, and if you don't know where to start or just look for inspiration, go check out the app i tested, it's a great example of an app made with all the new nextjs sweet features.
made by
@shadcn
I don’t know if I am wrong but it seems to me that the
@vercel
dashboard has now been fully migrated to app router, I would like to see a post mortem of this migration, the pain points, the benefits, the patterns discovered along, etc
There are definitely things to learn from it
@AdamRackis
@jjenzz
@mikeour
@fridayfrontend
@samselikoff
For the breadcrumb example, you do : `@ breadcrumbs/[…paths]/page.tsx` and in your layout :
function Layout({ breadcrumbs, children }) {
return (
<main>
{breadcrumbs}
{children}
</main>
)}
From the breadcrumbs page paths will contains all the routes segments
Could the docs around cache invalidations in
@nextjs
(with ISR, revalidate methods and client side router cache) be more detailled ?
Today I just learned that you have to call `/dynamic-path/[id]` instead of `/dynamic-path/1` to issue a revalidation of a dynamic segment.
I hate
@DrizzleORM
because it is so easy to convert from SQL to drizzle, like how dare you have so close to SQL and still be typesafe ? 😠
Do you need to be so damn enjoyable to work with ?
I GOT IT WORKING BABY 🥳 !
A cached server component with `unstable_cache`, containing a client component.
thanks to
@lubieowoce
for giving me a BIG headstart for how it could work 🙏.
link to code :
DISCLAIMER : __DO_NOT_USE_OR_YOU_WILL_BE_FIRED !!!
Does anyone have any idea how i could cache the output of some components ? (Server component especially)
I have a <Markdown> component that can be slow or fast because it has to parse a string, do some DB queries, do some logic, and then return some JSX
Found this cool PR on the react repo : "Taint APIs"
:
In summary, It introduces APIs to block some values to be sent to the client, like an API KEY (stripe API KEY for ex), you can mark the value as tainted and it will error if it ends up in the client.
This is by far one of most exciting PRs in nextjs 😁, If this is stable, that means that other providers can use this to setup the nextjs data-cache using their own KV solution with ease.
→
Man building an app front to back is not easy, especially when you are dealing with a complex UI, that also needs a complex backend.
Like this search dropdown is very complex with so many filters and many syntax variants, the (SQL) search query it generates also is very complex.
Upgraded this example with the latest next canary and now i can just return JSX for the popup inside an action. This is pretty cool for implementing patterns like twitter & github hovercards.
Bonus point : no extra JS shipped for the component
@asidorenko_
One thing :
Don’t replace action with a client action in the form or you will loose progressive enhancement, keep the action prop and do your logic inside onSubmit (with e.preventDefault) and build the formData to send to your action with `new FormData(e.currentTarget)`
My frontend people who started w/ react and other FW, how did you handle client side forms before the coming of "progressive enhanced" FW ?
Didn't you use a <form> component whenever possible ? Or did you use something else ?
One useful pattern that is interesting with server actions is higher order functions, you can use them as some sort of middleware or validation layer, so that you don't repeat that logic inside of your action.
With one line, i can add authentication & authorization to an action
I’ve decided to start yet another project, this one more involved, still not commercial (because I don’t like the stress and responsibilities of doing so) but that I would like to use for other projects, so what is it ?
A PaaS for self hosting your apps
#buildinginpublic
1/
@mhevery
There are libs that use contexts with an external cache (take zustand or react-query) that already solve prop-drilling. Sure they don’t act like signals with in place updating of the HTML, but they help with rendering only the component that needs it.
React form (client/server) actions + useFormState + zod = ❤️
Handling forms without tracking every input is just so simpler, and actually enjoyable for once 😅
This was long awaited, i've been using server actions for a long time everywhere in my apps.
They are just such a great abstraction for mutations and even data-fetching, they work great with React-Query and the icing on top : you put them in a form and you have PE for free 😁
Server Actions are now in React Canary, ready for frameworks and libraries to adopt! Server Actions are functions created alongside your components that run on the server for tasks like data mutations