Next.js Discord

Discord Forum

how to import cache handler on next config.mjs?

Unanswered
Fire ant posted this in #help-forum
Open in Discord
Fire antOP
Got this error
 âš  Invalid next.config.mjs options detected:
 âš      Expected string, received function at "cacheHandler"
 âš  See more info here: https://nextjs.org/docs/messages/invalid-next-config
using create next app.
My old next 13 is using .js, so how to import the cache handler in next config mjs?
ref https://nextjs.org/docs/app/api-reference/next-config-js/incrementalCacheHandlerPath

my next config.mjs
import cacheHandlers from "./cache-handler.js";

const nextConfig = {
  cacheHandler: cacheHandlers,
...

5 Replies

Fire antOP
.
.
Th equivalent of require.resolve() in ESM
Note the Node.js version requirement though