Next.js Discord

Discord Forum

Is this asset management approach anti-pattern for Next.js?

Unanswered
Gray Silky-flycatcher posted this in #help-forum
Open in Discord
Gray Silky-flycatcherOP
Hi everyone! I've recently joined a project that uses a custom script for handling static assets, and I'm trying to understand if this is a common/standard practice in the Next.js ecosystem.

The Current Setup in the Project:
The project has a script that auto-generates a type-safe manifest for all static assets.

You run bun run r once, and it watches for file changes
It generates an object with constants for all assets (images, SVGs, etc.)

The usage looks like this:

// 1. Import the generated manifest
import { R } from "@/lib/code-gen/output/R";

// 2. Use with full IntelliSense
<Image
src={R.images.svgs.single_icon}
alt="An icon"
/>

My Concern:
While this provides nice autocomplete and seems type-safe, I'm used to the standard Next.js approach of using direct paths:

// What I'm familiar with from Next.js docs
<Image
src="/svgs/single-icon.svg"
alt="An icon"
/>

Having worked with Next.js for a while, this custom approach feels a bit unconventional to me.

I'm wondering:

Is this kind of asset management approach common in larger Next.js projects?
Are there any potential downsides compared to the standard public directory approach?
Does this interfere with any Next.js optimizations or built-in features?
Would you recommend keeping this setup or migrating to the standard approach?
Would appreciate any insights from those who've worked on larger codebases or have seen similar setups!

Thanks! :thank_you:

0 Replies