how to extend my web application using plugins that I can load dynamically

I was wondering how do websites have a plugin system where they can extend the functionality of their website. if I have a manifest file containing the entry points for the plugin such as the main.js and main.html and so forth, how can I inject the ui in my web app as well as how to communicate between the host and the plugin using events and states, essentially making the plugin context aware. it would be ideal if you could provide concrete examples on how to do it, preferably in react.js and node.js.