Skip to content
This repository has been archived by the owner on Mar 3, 2021. It is now read-only.

How to load dynamic sub-components from an NPM package with next.js

Notifications You must be signed in to change notification settings

grouparoo/next-plugins-example

Repository files navigation

Next.js Plugins Example

Node.js CI

Read more about this project @ www.grouparoo.com/blog/nextjs-plugins

An example of how to use a dynamic import to load a page from a random plugin outside of the main next "pages" directory. We have a monorepo, which we will be using Lerna to manage. We have a server project which is our main application and plugins which contain plugins the server can use. The plugin, my-nextjs-plugin contains a page, /pages/hello.tsx, which we want the main application to display.

  • server is the root project
  • plugins contains the plugins with additional pages and components we want to display in the main application

To Start:

npm install
npm run dev