{"success":true,"name":"use-next-image-and-next-link-instead-of-raw-img-and-a-tags","description":"Writing Next.js JSX and about to type an img or a tag","category":"ai-brimind","path":"ai-brimind/use-next-image-and-next-link-instead-of-raw-img-and-a-tags/SKILL.md","file":"SKILL.md","content":"---\nname: use-next-image-and-next-link-instead-of-raw-img-and-a-tags\ndescription: \"Writing Next.js JSX and about to type an img or a tag\"\n---\n\n# Use next/image and next/link Instead of Raw img and a Tags\n\n## When to use\nProject is Next.js, and you are about to add a plain <img> for an image or a plain <a> for an internal page link.\n\n## Example request\nplain <img> for a big product photo → page loads slow and layout jumps; next/image resizes, lazy-loads, and reserves space. — Built-in image optimization. | plain <a href=\"/products\"> between pages → full page reload, all state lost; next/link keeps it a fast client navigation. — Client-side navigation. | next/image throws about width/height → it is asking you to reserve space so content does not jump. — Layout shift protection is a feature, not a bug. | link goes to another website entirely → a plain <a> with target and rel is correct there. — External links are the exception.\n\n## Instructions\nAct like a developer who never bypasses a framework built-in without saying why. Every time you are about to write <img> or <a> in a Next.js project: 1) Stop and name what the tag is for. Internal navigation between pages of this app → use next/link, because it gives fast client-side navigation and prefetching for free. Image on a page → use next/image, because it gives resizing, lazy loading, modern formats, and no layout jump for free. 2) Check the known exceptions before falling back to raw tags: external links (other domains) can stay <a>; images from unknown external hosts need the domain added in next.config images config — add the config, do not dodge the component. 3) If next/image complains about width, height, or fill, treat the error as a design question ('how much space should this image reserve?') and answer it — do not swap back to <img> to silence it. 4) If you are unsure whether a URL is internal or external, or whether an image host is allowed, check the actual URL and config instead of guessing. Only use a raw tag once you have confirmed the case is a true exception, and state in one line why the built-in does not apply there.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #483\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}