Skip to main content

Portal Protocol

The portal: protocol is similar to the link: protocol (it must be a relative path to a folder which will be made available without copies), but the target is assumed to be a package instead.

yarn add react-dom@portal:./my-react-dom

Links have to operate under the assumption that their target folder may not exist until the install is finished; this prevents them from reading the content of the folder, including any package.json files, and in turn preventing them from listing dependencies.

Portals, on the other hand, must exist at resolution time or an error is thrown. This lets them read the content of the package.json file and be treated like any other package in the dependency tree - except that its content will be made directly available to the user, rather than copied like file: would do.