Implicit Integration

In this guide, users will learn tips and recommendations on using OnePub with the Dart CLI tools.

OnePub supports both explicit and implicit integration.

Recommendation: It is recommended to use explicit Integration unless you have an Enterprise license.

Personally, we recommend using Explicit Integration as it allows the users to make the most of OnePub at the cost of a minor change to each of their pubspec.yaml files.

Explicit Integration

With explicit integration, a user needs to modify each pubspec.yaml file that uses or publishes a private package.


  • Only requires the user to run onepub login and they are fully configured

  • using publish_to in your pubspec stops the package from being accidentally published to

  • Dependencies work for other users without any environment configuration

  • No configuration is required for your IDE


  • Users need to explicitly configure each Private Dependency

Configure a package to be published to OnePub

You can edit your pubspec.yaml file manually or use the onepub private command. The outcome is the same, using the onepub command is faster.

Use the onepub private command.

cd mypackage
onepub pub private
# now publish your package to OnePub
dart pub publish

Manually edit pubspec.yaml

Login to OnePub and copy the `publish_to:` url from the profile page:

Add a publish_to key to your pubspec.yaml.

name: onepub
version: 1.1.0

# Set onepub as the publish target.

Now publish your package

cd mypackage
dart pub publish

Configure a OnePub dependency

Once you have published a package to OnePub you are going to want to update your projects to use the package from OnePub.

You can either manually edit your pubspec.yaml or use the onepub cli tools to do the work for you.

Use the onepub add command

To add or change a package dependency to get the package from OnePub run:

cd <my project>
onepub pub add [--dev] <package>

Use the --dev switch to add the package as a dev dependency.

If the package already exists as a dependency the onepub will simply update the hosted-url to point to OnePub.

Manually configure a OnePub dependency

For each project that depends on a private package, you can add a hosted key.

Copy the 'publish_to' URL from your profile page:

Now paste it into the 'hosted' key for the package.

    version: 1.0.2

If your dart version is older than 2.15, then you must use the older hosted format.

    version: 1.0.2
      name: my_private_package

Implicit Integration

Implicit Integration involves setting the PUB_HOSTED_URL environment variable.

Copy the publish_to url from your profile page:

Now add the PUB_HOSTED_URL environment variable to your system.

Add an export statement to your ~/.bashrc file:


Restart your shell and check the environment variable is available.

Once it is configured, all requests made by the pub command are sent to your OnePub private repo.

This method is still able to get public packages.


  • No need to configure each package and dependency

  • Restrict devs to only using packages from verified publishers (Enterprise Edition)

  • Constrain what packages your team can use via a OnePub curated list (Enterprise Edition)


  • Users need to configure an environment variable

  • Risk of users accidentally publishing a private to

Last updated