Google News
logo
Next.js - Interview Questions
How to URL Imports in Next.js?
URL imports are an experimental feature that allows you to import modules directly from external servers (instead of from the local disk).
 
Warning : This feature is experimental. Only use domains that you trust to download and execute on your machine. Please exercise discretion, and caution until the feature is flagged as stable.
 
To opt-in, add the allowed URL prefixes inside next.config.js :
module.exports = {
  experimental: {
    urlImports: ['https://example.com/modules/'],
  },
}
Then, you can import modules directly from URLs :
import { a, b, c } from 'https://example.com/modules/some/module.js'
URL Imports can be used everywhere normal package imports can be used.
Advertisement