👇 Creating and receiving Structured Output from AI responses for a chatbot with OpenAI + LangChain in a React application.
👇 Creating and receiving Structured Output from AI responses for a chatbot with OpenAI + LangChain in a React application.
👇 HTTP streaming AI responses for a chatbot with OpenAI + LangChain in a React application.
👇 HTTP streaming AI responses for a chatbot with OpenAI + LangChain in a React application.
👇 MVP for creating a chatbot with OpenAI + LangChain in a React application.
👇 MVP for creating a chatbot with OpenAI + LangChain in a React application.
The function signatures of server actions adapt depending on how they are used within a React form.
The function signatures of server actions adapt depending on how they are used within a React form.
How to approach server-side form validation with server-driven React while also being able to optionally add client-side form validation later.
How to approach server-side form validation with server-driven React while also being able to optionally add client-side form validation later.
Server Components won't eliminate waterfall requests, they only shift where these requests occur.
As a result, using the correct data-fetching patterns remains just as critical in server-driven React applications as it has always been in client-side React.
Server Components won't eliminate waterfall requests, they only shift where these requests occur.
As a result, using the correct data-fetching patterns remains just as critical in server-driven React applications as it has always been in client-side React.
In a growing application, it's easy for different domains to become intertwined.
For example, in the UI, a Comment component can quickly end up inside a Post component, and a data-fetching function might be extended beyond its original purpose.
In a growing application, it's easy for different domains to become intertwined.
For example, in the UI, a Comment component can quickly end up inside a Post component, and a data-fetching function might be extended beyond its original purpose.
Compared to all the pre-made Next.js starter kits out there, The Road to Next teaches you the knowledge to create your own from scratch.
Compared to all the pre-made Next.js starter kits out there, The Road to Next teaches you the knowledge to create your own from scratch.
Dealing with FormData will become inevitable in React 19. From extracting the data in a concise yet descriptive way to validating and typing it.
Dealing with FormData will become inevitable in React 19. From extracting the data in a concise yet descriptive way to validating and typing it.
I like to use kebab-case for all my files, even React components. Many freelance gigs have taught me over the years that kebab-case (or snake_case) is the most reliable way to handle file names across OSs with various case-sensitivity when sharing code with version control.
I like to use kebab-case for all my files, even React components. Many freelance gigs have taught me over the years that kebab-case (or snake_case) is the most reliable way to handle file names across OSs with various case-sensitivity when sharing code with version control.
There are multiple ways to fetch data in modern React:
👉 Server-Side 1️⃣
👉 Client-Side 2️⃣
1️⃣ React Server Components (RSC)
2️⃣ React Query (RQ)
1️⃣ + 2️⃣ RSC + RQ
1️⃣ + 2️⃣ React's use API (experimental)
2️⃣ useState + useEffect
2️⃣ tRPC (type-safe E2E)
There are multiple ways to fetch data in modern React:
👉 Server-Side 1️⃣
👉 Client-Side 2️⃣
1️⃣ React Server Components (RSC)
2️⃣ React Query (RQ)
1️⃣ + 2️⃣ RSC + RQ
1️⃣ + 2️⃣ React's use API (experimental)
2️⃣ useState + useEffect
2️⃣ tRPC (type-safe E2E)
JS .bind() is becoming popular again! What ended with Class Components in React reclaims its spotlight with Server Actions once more.
JS .bind() is becoming popular again! What ended with Class Components in React reclaims its spotlight with Server Actions once more.
Organizing React applications beyond 100,000 lines of code 🫠
Folder structures in React tend to be a highly debated topic. Each year, I revisit and refine my approach to organizing React applications.
Let's dive into this 5-step plan.
Organizing React applications beyond 100,000 lines of code 🫠
Folder structures in React tend to be a highly debated topic. Each year, I revisit and refine my approach to organizing React applications.
Let's dive into this 5-step plan.
Functions tend to evolve over time, often gaining more logic. What starts as a simple "fetch posts by a user" can quickly turn into "fetch posts by a user with specific search, sort, pagination, and other criteria."
To address this, I've started using Options Objects 👇
Functions tend to evolve over time, often gaining more logic. What starts as a simple "fetch posts by a user" can quickly turn into "fetch posts by a user with specific search, sort, pagination, and other criteria."
To address this, I've started using Options Objects 👇
URL state is often overlooked. I implemented it in most of my freelance projects over the years, and it had always a big impact on the UX.
Libraries for URL state give you:
👉 typed search parameters
👉 reading and writing to/from URLs
👉 both simple and complex data types
URL state is often overlooked. I implemented it in most of my freelance projects over the years, and it had always a big impact on the UX.
Libraries for URL state give you:
👉 typed search parameters
👉 reading and writing to/from URLs
👉 both simple and complex data types
This approach allows you to maintain a component as a Server Component while still performing an operation by clicking the button.
*not a new pattern in HTML itself
This approach allows you to maintain a component as a Server Component while still performing an operation by clicking the button.
*not a new pattern in HTML itself
Server Actions can be used to fetch data in Client Components, but it's not recommended. Drawbacks:
❌ Limited to HTTP POST
❌ Executed Sequentially
❌ ... ?
That's why Server Actions are becoming a subset of Server Functions! Eventually they will allow you to fetch data.
Server Actions can be used to fetch data in Client Components, but it's not recommended. Drawbacks:
❌ Limited to HTTP POST
❌ Executed Sequentially
❌ ... ?
That's why Server Actions are becoming a subset of Server Functions! Eventually they will allow you to fetch data.
The image below lives rent-free in my head 🙃 Server Components and Server Actions will transform React into a full-stack framework ✨ Personally, I've come to embrace this paradigm shift!
#ReactJS
https://buff.ly/47JsHZG
The image below lives rent-free in my head 🙃 Server Components and Server Actions will transform React into a full-stack framework ✨ Personally, I've come to embrace this paradigm shift!
#ReactJS
https://buff.ly/47JsHZG
There are two ways to send extra arguments with Server Actions:
👉 HTML input with type="hidden"
👉 JavaScript .bind() on the server action
The latter often requires explanation for non-native JavaScript developers on a team. That's why I prefer the former.
#ReactJS
There are two ways to send extra arguments with Server Actions:
👉 HTML input with type="hidden"
👉 JavaScript .bind() on the server action
The latter often requires explanation for non-native JavaScript developers on a team. That's why I prefer the former.
#ReactJS