Skip to content

Instantly share code, notes, and snippets.

View pfftdammitchris's full-sized avatar
💭
Dreaming

Christopher Tran pfftdammitchris

💭
Dreaming
View GitHub Profile
@pfftdammitchris
pfftdammitchris / snippet-1.sh
Created November 21, 2026 06:05
Next.js DevIndicators and `appIsrStatus` in 2026: Reading Rendering Mode at a Glance During Development - snippet-1.sh
Route (app)
┌ ○ /_not-found
└ ƒ /products/[id]
○ (Static) prerendered as static content
ƒ (Dynamic) server-rendered on demand
@pfftdammitchris
pfftdammitchris / snippet-2.ts
Created November 21, 2026 06:05
Next.js DevIndicators and `appIsrStatus` in 2026: Reading Rendering Mode at a Glance During Development - snippet-2.ts
import type { NextConfig } from 'next';
const nextConfig: NextConfig = {
devIndicators: {
position: 'bottom-right', // 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right'
},
};
export default nextConfig;
@pfftdammitchris
pfftdammitchris / snippet-3.ts
Created November 21, 2026 06:05
Next.js DevIndicators and `appIsrStatus` in 2026: Reading Rendering Mode at a Glance During Development - snippet-3.ts
const nextConfig: NextConfig = {
devIndicators: false,
};
export default nextConfig;
@pfftdammitchris
pfftdammitchris / snippet-4.ts
Created November 21, 2026 06:05
Next.js DevIndicators and `appIsrStatus` in 2026: Reading Rendering Mode at a Glance During Development - snippet-4.ts
// app/profile/page.tsx
import { cookies } from 'next/headers';
export default async function ProfilePage() {
const isDevelopment = process.env.NODE_ENV === 'development';
// Conditional request-time API usage
const userCookie = isDevelopment ? undefined : await cookies().get('user');
return <div>Profile: {userCookie?.value ?? 'Guest'}</div>;
@pfftdammitchris
pfftdammitchris / snippet-5.ts
Created November 21, 2026 06:05
Next.js DevIndicators and `appIsrStatus` in 2026: Reading Rendering Mode at a Glance During Development - snippet-5.ts
// app/posts/page.tsx
export default async function PostsPage() {
// Uncached fetch opts out of static rendering
const response = await fetch('https://api.example.com/posts');
const posts = await response.json();
return <div>{posts.map(/* ... */)}</div>;
}
@pfftdammitchris
pfftdammitchris / snippet-1.ts
Created November 20, 2026 06:06
Next.js `revalidatePath` vs `revalidateTag` in 2026: Choosing the Right Cache Invalidation Primitive at Scale - snippet-1.ts
import { revalidatePath } from 'next/cache'
export async function updateProduct(productId: string, data: ProductData) {
await db.product.update({
where: { id: productId },
data
})
// Invalidates all cached data for /products and its dynamic segments
revalidatePath('/products')
@pfftdammitchris
pfftdammitchris / snippet-2.ts
Created November 20, 2026 06:06
Next.js `revalidatePath` vs `revalidateTag` in 2026: Choosing the Right Cache Invalidation Primitive at Scale - snippet-2.ts
import { cacheTag } from 'next/cache'
export async function getProduct(id: string) {
'use cache'
cacheTag(`product:${id}`)
return db.product.findUnique({
where: { id }
})
}
@pfftdammitchris
pfftdammitchris / snippet-3.ts
Created November 20, 2026 06:06
Next.js `revalidatePath` vs `revalidateTag` in 2026: Choosing the Right Cache Invalidation Primitive at Scale - snippet-3.ts
import { revalidateTag } from 'next/cache'
export async function updateProduct(productId: string, data: ProductData) {
await db.product.update({
where: { id: productId },
data
})
// Invalidates the product everywhere it appears
revalidateTag(`product:${productId}`)
@pfftdammitchris
pfftdammitchris / snippet-4.ts
Created November 20, 2026 06:06
Next.js `revalidatePath` vs `revalidateTag` in 2026: Choosing the Right Cache Invalidation Primitive at Scale - snippet-4.ts
import { unstable_cache } from 'next/cache'
// Tag-based approach for shared data
export const getCachedProduct = unstable_cache(
async (id: string) => {
return db.product.findUnique({
where: { id },
include: {
category: true,
reviews: {
@pfftdammitchris
pfftdammitchris / snippet-5.ts
Created November 20, 2026 06:06
Next.js `revalidatePath` vs `revalidateTag` in 2026: Choosing the Right Cache Invalidation Primitive at Scale - snippet-5.ts
'use server'
import { revalidateTag, revalidatePath } from 'next/cache'
export async function updateProduct(
id: string,
data: ProductUpdateInput
) {
const product = await db.product.update({
where: { id },