startUrl

  • Type: boolean | string | string[] | undefined
  • Default: undefined

The dev.startUrl is used to set the URL of the page that will be automatically opened in the browser when the server starts.

By default, when the dev server or preview server starts, no page will be automatically opened. You can use dev.startUrl or the --open CLI param to set the automatic opening of a page.

Example

You can set it to the following values:

export default {
  dev: {
    // Open the project's default preview page, equivalent to `http://localhost:<port>`
    startUrl: true,
    // Open the specified page
    startUrl: 'http://localhost:8080',
    // Open multiple pages
    startUrl: ['http://localhost:8080', 'http://localhost:8080/about'],
  },
};

Port placeholder

Since the port number may change, you can use the <port> placeholder to refer to the current port number, and Rsbuild will automatically replace the placeholder with the actual listening port number.

export default {
  dev: {
    startUrl: 'http://localhost:<port>/home',
  },
};

Open the specified browser

On MacOS, you can open the specified browser when Dev Server starts, by set environment variable BROWSER, support values:

  • Google Chrome Canary
  • Google Chrome Dev
  • Google Chrome Beta
  • Google Chrome
  • Microsoft Edge
  • Brave Browser
  • Vivaldi
  • Chromium
TIP

It is recommended to set it in the local .env.local file.