Tutorial

Getting Started with Code Owners

Learn how to set up Code Owners for your codebase.
Table of Contents

Code Owners are available on Enterprise plans

To set up Code Owners in your repository, you'll need to do the following:

If you've already set up Conformance, you may have already completed some of these steps.

To enable Code Owners for your Enterprise team, you'll need to request access through your Vercel account administrator.

Note: Code Owners is available for Enterprise teams. To add it to your contract or upgrade to Enterprise, contact us

Contact Sales

Vercel distributes packages with the @vercel-private scope through our private npm registry, and requires that each user using the package authenticates through a Vercel account.

To use the private npm registry, you'll need to follow the documentation to:

A GitHub App enables Code Owners functionality by adding reviewers and enforcing review checks for merging PRs.

  1. The Code Owners CLI is separate to the Vercel CLI, however it uses the Vercel CLI for authentication.

    Before continuing, please ensure that the Vercel CLI is installed and that you are logged in.

  2. If you have an existing CODEOWNERS file in your repository, you can use the CLI to automatically migrate your repository to use Vercel Code Owners. Otherwise, you can skip this step.

    Start by running this command in your repository's root:

    pnpm
    yarn
    npm

    pnpm --package=@vercel-private/code-owners dlx vercel-code-owners init

    yarn dlx only works with Yarn version 2 or newer, for Yarn v1 use the npx command.

    After running, check the installation success by executing:

    pnpm
    yarn
    npm

    pnpm vercel-code-owners

  3. To install, you must be an organization owner or have the GitHub App Manager permissions.

    1. Go to https://github.com/apps/vercel/installations/new
    2. Choose your organization for the app installation.
    3. Select repositories for the app installation.
    4. Click Install to complete the app installation in the chosen repositories.
  4. After installation, define Code Owners files in your repository. Pull requests with changes in specified directories will automatically have reviewers added.

    Start by adding a .vercel.approvers file in a directory in your repository. List GitHub usernames or team names in the file, each on a new line:

    .vercel.approvers
    @username1
    @org/team1

    Then, run the validate command to check the syntax and merge your changes into your repository:

    pnpm
    yarn
    npm

    pnpm vercel-code-owners validate

  5. With the .vercel.approvers file merged into the main branch, test the flow by modifying any file within the same or child directory. Create a pull request as usual, and the system will automatically add one of the listed users as a reviewer.

  6. This step is optional

    By default, GitHub checks are optional and won't block merging. To make the Code Owners check mandatory, go to Settings > Branches > [Edit] > Require status checks to pass before merging in your repository settings.

Last updated on July 23, 2024