frontend
Technical notes on web development, DevOps, and AI integration.
173 articles
- 23:18frontend
Turning 113 Client Logos into a Pure CSS Marquee
A 113-logo client grid pushed everything below the fold. I rebuilt it as a pure CSS two-row marquee with an exact -50 percent loop.
TL;DR: A 113-logo static grid buried the homepage content, so I replaced it with a pure CSS marquee instead of pulling in a JS library. Two duplicated tracks animate translate3d from 0 to -50%, with flex gap folded into padding so the loop seams perfectly. Transform-only animation, edge fades via mask-image, aria-hidden tiles, and prefers-reduced-motion keep it fast and accessible.
#css#nextjs#accessibility - 22:22frontend
Splitting a Giant Logo Wall into 113 Clean Tiles
How I cut one client-logo wall raster into 113 uniform tiles: whitespace segmentation, a 220x130 canvas, and a stable next/image grid.
TL;DR: A single giant client-logo raster gets split deterministically using whitespace projection and connected components, no machine learning needed. Each crop is normalized onto a 220x130 white canvas so the grid stays tidy without stretching. The frontend uses next/image with explicit dimensions, lazy loading, and slot-based naming to prevent layout shift and keep pruning safe.
#nextjs#next-image#performance - 21:17frontend
React 19 Script Tag Warning in Next.js and the next-themes Fix
React 19 flags every script tag inside a component, including the next-themes anti-FOUC script that actually runs. Here is how I silence it in dev only.
TL;DR: next-themes renders an inline script to prevent theme flash, but React 19 warns about every script tag in components, producing a harmless false positive on Next.js 16. Since the open issue won't get fixed soon, I shipped a dev-only console.error filter that silences that exact message. Production stays untouched, and dark mode keeps working without FOUC.
#react#nextjs#next-themes - 18:35frontend
Why I Put 92% Alpha in My Header Token Instead of Using bg-white/60
Dark navy header felt heavy in light mode. The fix: bake 92% alpha into the --color-header token so backdrop-blur works everywhere without per-component overrides.
TL;DR: Slapping bg-white/60 on a navbar breaks fast, since child elements inherit transparency and fixes scatter across files. The fix is baking alpha into a --color-header token (about 92 percent opacity), which cascades to every consumer and pairs cleanly with backdrop-blur-md. Trade-off: the header decouples from the global background token, but one line brings it back if needed.
#css#tailwind#design - 15:01frontend
Moving the Next.js Root Layout Made Tailwind Disappear
A missing globals.css import after moving the root layout into app/[locale] stripped every page of styling — while the build stayed green.
TL;DR: An i18n refactor moved the Next.js root layout into app/[locale]/layout.tsx and accidentally dropped the globals.css import. Without that file Tailwind v4 never loaded, so the site rendered as unstyled HTML while the build stayed green. The fix was re-adding the import, a reminder to visually check pages and grep for globals.css after layout changes.
#nextjs#tailwindcss#css - 14:35seo
Two Route Handlers for llms.txt, Zero Drift
Adding llms.txt route handlers to a bilingual Next.js App Router site and generating the file from the same content modules the pages render.
TL;DR: The author initially assumed llms.txt was a sitemap for LLMs, but it's actually a small curated markdown overview agents fetch on demand, with no SEO payoff today. They added two Next.js route handlers serving it as static plain text with caching. The key takeaway: generate it from the same content modules as your pages to prevent drift.
#nextjs#llms-txt#aeo - 13:49frontend
Why I Stopped Patching HTML lang Client-Side in Next.js
Moving the root layout into the [locale] segment makes html lang server-rendered, deletes the client-side language bootstrap, and passes the structural audit.
TL;DR: We replaced a client-side script that guessed the reader's language with Next.js's recommended pattern: nesting the root layout under a dynamic locale segment so the lang attribute renders correctly on the server. This brought free 404s for unknown locales, static prerendering, and correct screen-reader pronunciation, even on 404 pages. Detection now lives in an Accept-Language redirect instead.
#nextjs#i18n#html - 13:30frontend
The Three Metadata Layers Behind a Clean Next.js SEO Audit
Canonical, hreflang, metadataBase, and JSON-LD LocalBusiness: the three layers that made sixteen bilingual Next.js routes pass an SEO audit.
TL;DR: Sixteen bilingual Next.js routes passed a full SEO audit thanks to one metadata commit. Three layers did the work: a shared helper generating canonical and hreflang tags, metadataBase in the root layout, and JSON-LD marking up the business and website. Centralizing everything keeps URLs consistent, so new routes stay audit-proof instead of relying on Google to guess.
#nextjs#seo#i18n - 11:46frontend
A Next.js Locale Switcher That Doesn't Lose Your Visitor
Build a Next.js App Router locale switcher that preserves the current path with usePathname and a regex swap, plus an accessible active state.
TL;DR: A naive locale switcher sent users to the locale homepage instead of the same page. The fix: a small client component that swaps the /en or /id prefix while preserving the rest of the pathname, plus aria-current for the active state. Stick with this for simple sites; adopt next-intl once routing grows complex.
#nextjs#i18n#accessibility