From Next.js 12, support for ES Modules is now enabled by default, as long as the ESM library has "type": "module"
in its package.json
. Using next-transpile-modules
to transpile ESM libraries is no longer required.
Before Next.js 12
Since ky
is exported as ESM you can transpile it with next-transpile-modules
in next.config.js
.
// next.config.js
const withTM = require('next-transpile-modules')(['ky']);
module.exports = withTM(/* your Next.js config */);