Skip to content
Daily Dev Tip
MI

Mohamed Idris

@hnooz

45 tips merged·go, laravel, nest, next, nuxt, php, react, rust, vue·member since July 2026
github.com/hnooz

Tips by @hnooz

Unwrap errors type-safely with errors.AsType (Go 1.26)

GO

errors.AsType[E] (Go 1.26) is a generic, type-safe version of errors.As. It returns the matched error and a boolean ins…

go1.26errors
@hnooz

Sandbox filesystem access to a directory with os.Root (Go 1.24)

GO

os.Root (Go 1.24) confines all file operations to a directory: Open, Create, Stat, and friends resolve relative to the…

go1.24filesystem
@hnooz

Write custom iterators with range-over-func (Go 1.23+)

GO

Go 1.23 lets functions of type iter.Seq[V] be consumed by for range. You return a function that calls yield for each el…

go1.23iterators
@hnooz

Use b.Loop() for accurate benchmarks (Go 1.24)

GO

b.Loop() (Go 1.24) is the new benchmark loop. Beyond being cleaner than for i := 0; i < b.N; i++, it keeps setup outsid…

go1.24testing
@hnooz

Track tool dependencies in go.mod with tool directives (Go 1.24)

GO

Go 1.24 tracks executable dependencies with tool directives in go.mod, retiring the old tools.go blank-import hack. go…

go1.24modules
@hnooz

Attach request-scoped metadata with the Context facade so it flows into logs and jobs

LARAVEL

The Context facade (Laravel 11+) stores key/value data for the current request that's automatically added to every log…

observabilitylogging
@hnooz

Turn N+1 queries into errors in development with preventLazyLoading()

LARAVEL

Called in a service provider, this throws a LazyLoadingViolationException whenever a relation is accessed without being…

eloquentperformance
@hnooz

Lock down outbound HTTP in tests with preventStrayRequests()

LARAVEL

Http::fake() alone lets un-matched requests fall through to the real network, which makes tests flaky and slow and can…

testinghttp-client
@hnooz

Auto-delete stale records with the Prunable trait instead of a custom command

LARAVEL

Add Prunable and a prunable() query, and model:prune (scheduled) deletes matching rows in chunks — no bespoke cleanup c…

eloquentmaintenance
@hnooz

Use whenLoaded() in API resources to avoid firing queries during serialization

LARAVEL

Referencing $this->posts directly in a resource lazy-loads the relation for every model when it wasn't eager-loaded — a…

eloquentapi-resources
@hnooz

Throw IntrinsicException for expected errors to skip Nest's auto-logger

NESTJS

NestJS 11 added IntrinsicException: throwing it bypasses the framework's automatic error logging while still propagatin…

nestjs11exceptions
@hnooz

Validate and convert date query params at the boundary with ParseDatePipe

NESTJS

NestJS 11 ships ParseDatePipe, which validates an incoming date string and hands your handler a real Date. Parsing date…

nestjs11pipes
@hnooz

Skip the HTTP layer for workers and CLI with createApplicationContext()

NESTJS

createApplicationContext() boots the DI container without starting an HTTP server. For cron jobs, queue consumers, and…

nestjsworkers
@hnooz

Keep the SWC builder (default in Nest 11) for ~20x faster builds

NESTJS

Nest 11 defaults to the Rust-based SWC compiler, which is dramatically faster than tsc for builds and dev restarts. SWC…

nestjs11build
@hnooz

Configure a strict global ValidationPipe to strip unknown fields and coerce DTOs

NESTJS

whitelist: true removes any property not declared with a validation decorator — your defense against mass-assignment, s…

nestjsvalidation
@hnooz

Push 'use client' to leaf components and pass server data down as props

NEXT

Everything in the App Router is a Server Component until you add 'use client', and that directive taints the whole subt…

nextjs15server-components
@hnooz

Remember GET route handlers are uncached by default since Next.js 15

NEXT

Next.js 15 flipped the default: GET route handlers and the client router cache are no longer cached unless you opt in.…

nextjs15caching
@hnooz

Invalidate exactly what changed with revalidateTag/revalidatePath after writes

NEXT

After a mutation, invalidate the specific cache entries it affected rather than forcing a broad refresh or client reloa…

nextjs15caching
@hnooz

Use Server Actions for internal mutations instead of hand-rolled API routes

NEXT

Server Actions run mutation logic on the server and can be called directly from a <form action> or a client handler — n…

nextjs15server-actions
@hnooz

Stream slow sections with loading.tsx and Suspense instead of blocking the route

NEXT

A route-level loading.tsx wraps the page in a Suspense boundary so the shell streams immediately while data loads. Wrap…

nextjs15streaming
@hnooz

Cache expensive server routes at the edge with defineCachedEventHandler

NUXT

Nitro's defineCachedEventHandler wraps a server route with stale-while-revalidate caching backed by your configured sto…

nuxt4nitro
@hnooz

Set per-route rendering strategy with routeRules instead of restructuring code

NUXT

routeRules applies a rendering mode per URL pattern in config, so marketing pages prerender, content pages use ISR, and…

nuxt4rendering
@hnooz

Give useAsyncData an explicit key to control dedup and caching

NUXT

useAsyncData dedups and caches by key. Without an explicit key Nuxt derives one from the call site, which can collide w…

nuxt4data-fetching
@hnooz

Share state across components with useState, never a module-level ref, on SSR

NUXT

On the server a module-level ref is created once and shared by every request, so one user's cart can leak into another'…

nuxt4state
@hnooz

Use useFetch in setup and $fetch in handlers to avoid double-fetching

NUXT

useFetch is the SSR-aware wrapper: it runs during server render, serializes the result into the payload, and hydrates o…

nuxt4data-fetching
@hnooz

Prefer asymmetric visibility over readonly when a class mutates its own state

PHP

public private(set) (PHP 8.4) makes a property readable from anywhere but writable only inside the class. readonly forb…

php8.4oop
@hnooz

Chain methods directly off constructors in PHP 8.4

PHP

PHP 8.4 allows new Foo()->method() without wrapping the instantiation in parentheses. It's a small ergonomic win that r…

php8.4syntax
@hnooz

Add #[\Override] in PHP 8.3 to catch broken method overrides at compile time

PHP

#[\Override] (PHP 8.3) tells the engine you intend to override a parent or interface method. If no matching method exis…

php8.3attributes
@hnooz

Use property hooks in PHP 8.4 to compute and validate without getter methods

PHP

PHP 8.4 lets a property define get/set hooks inline, so computed and validated values no longer need a separate method…

php8.4oop
@hnooz

Type your class constants in PHP 8.3 to lock the contract across subclasses

PHP

PHP 8.3 added type declarations for class, interface, and enum constants. Without a type, a subclass could override a c…

php8.3constants
@hnooz

Let the React Compiler memoize instead of hand-writing useMemo/useCallback

REACT

The React Compiler analyzes your components and automatically memoizes values and callbacks at build time, following th…

react19react-compiler
@hnooz

Drop forwardRef in React 19 and accept ref as a normal prop

REACT

React 19 lets function components receive ref as a regular prop, so forwardRef is no longer required for the common cas…

react19refs
@hnooz

Handle form mutations with built-in pending and error state via useActionState

REACT

useActionState wraps an async action and returns the last result, the action to bind to a <form action>, and a pending…

react19forms
@hnooz

Read promises and context conditionally with the use() hook

REACT

React 19's use() unwraps a promise or reads context, and unlike the Rules of Hooks it can be called conditionally or in…

react19suspense
@hnooz

Show instant UI with useOptimistic and auto-revert on failure

REACT

useOptimistic renders an expected next state immediately while the real async action runs, then reconciles to the true…

react19optimistic-ui
@hnooz

Pass inline async handlers with async closures and the AsyncFn traits (Rust 1.85)

RUST

Rust 1.85 stabilized async closures (async || { ... }) and the AsyncFn/AsyncFnMut/AsyncFnOnce traits. These let higher-…

rust1.85async
@hnooz

Use native async fn in traits and drop the async-trait crate

RUST

Since Rust 1.75, async fn works directly in traits (via return-position impl Trait), giving you static dispatch with ze…

rust1.75async
@hnooz

Flatten guard clauses with let ... else

RUST

let ... else binds a pattern or diverges — the else block must return, break, continue, or panic, so control flow leave…

rustpattern-matching
@hnooz

Future-proof public types with

RUST

#[non_exhaustive] on a public enum or struct forces downstream crates to include a wildcard arm when matching, and bloc…

rustapi-design
@hnooz

Control impl Trait lifetime capture precisely with use<> (Rust 2024)

RUST

In the Rust 2024 edition, return-position impl Trait captures every in-scope generic and lifetime by default. That's us…

rust2024impl-trait
@hnooz

Replace modelValue/update boilerplate with defineModel() for v-model

VUE

defineModel() returns a writable ref wired to the parent's v-model, collapsing the modelValue prop plus update:modelVal…

v-modelcomponents
@hnooz

Cancel stale async work in watchers with onWatcherCleanup()

VUE

Registered inside the watcher callback, onWatcherCleanup runs before the next invocation and on stop. It removes the ma…

watchersasync
@hnooz

Destructure props with native defaults in Vue 3.5, but pass a getter to watch

VUE

Stabilized in 3.5: destructured variables from defineProps compile to props.count on access, so they stay reactive and…

propsreactivity
@hnooz

Generate hydration-safe unique IDs with useId() for accessibility

VUE

useId() produces IDs that are stable and identical across server render and client hydration, so label/for and aria-des…

ssraccessibility
@hnooz

Use useTemplateRef() for typed template refs instead of string-matched refs

VUE

Vue 3.5 resolves template refs by key at runtime, so the type is inferred and you drop the ref(null) declaration that h…

composition-apirefs
@hnooz

Want to contribute? Submit a tip →