User Agents

Web browsers and everyday web tech, explained

Share User Data Between Chrome and Chrome Canary in Puppeteer

· 5 min read · Browsers

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Sharing user data between Chrome and Chrome Canary in Puppeteer allows you to maintain consistent browser sessions, cookies, extensions, and cached data across both stable and development versions of Chrome. This is particularly useful for testing features in Canary without losing login states or custom configurations from your regular Chrome profile. By configuring Puppeteer to use a shared user data directory, you can seamlessly switch between browsers while preserving session data. This guide walks you through setting up data sharing safely and effectively.

What You'll Need

  • Google Chrome installed on your system
  • Chrome Canary installed (available from the official Chrome website)
  • Puppeteer installed in your Node.js environment (via npm install puppeteer)
  • Basic knowledge of Node.js and JavaScript
  • Access to your system's file paths (user data directories)
  • A code editor or IDE for editing JavaScript files

Step-by-Step

  1. Locate your Chrome user data directory. On Windows, this is typically C:\Users\[Username]\AppData\Local\Google\Chrome\User Data. On macOS, it’s ~/Library/Application Support/Google/Chrome/. On Linux, it’s ~/.config/google-chrome/.
  2. Identify the specific profile folder you want to share. By default, this is the Default folder inside the User Data directory. If you use multiple profiles, choose the correct subfolder (e.g., Profile 1).
  3. Launch Chrome Canary with the same user data directory. In Puppeteer, you can specify the --user-data-dir argument to point to Chrome’s existing data folder. For example: args: ['--user-data-dir=/path/to/chrome/User Data'].
  4. Set the --profile-directory argument to match the profile you’re using. If using the default profile, add: '--profile-directory=Default'. For other profiles, adjust accordingly (e.g., Profile 1).
  5. Create a Puppeteer script that launches Chrome Canary using the shared data. Use puppeteer.launch() with the executablePath set to the Canary executable and include the args array with the user data and profile settings.
  6. On Windows, the executable path is usually C:\Users\[Username]\AppData\Local\Google\Chrome SxS\Application\chrome.exe. On macOS, it’s /Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary. On Linux, it may vary but often follows a similar pattern under /opt/ or /usr/bin/.
  7. Ensure no instances of Chrome or Chrome Canary are running before launching Puppeteer. Concurrent access to the same user data directory can cause profile corruption or data loss.
  8. Run your Puppeteer script. It should open Chrome Canary with your Chrome profile, including saved cookies, bookmarks, and login sessions.
  9. Verify the data is shared by logging into a site in regular Chrome, then opening the same site in Puppeteer-launched Canary. You should remain logged in.
  10. To reverse the process and share data from Canary to Chrome, repeat the steps but launch regular Chrome with Canary’s user data directory (located in a parallel path, e.g., Chrome SxS on Windows or Google Chrome Canary on macOS).

Common Mistakes

  • Forgetting to close existing Chrome instances before launching Puppeteer, which can lock the user data directory and cause crashes.
  • Using incorrect profile directory names, such as default instead of Default (case-sensitive on some systems).
  • Pointing to the wrong executable path for Chrome Canary, especially if the installation path differs from the default.
  • Assuming user data is automatically synced—Puppeteer does not sync data; it only shares access to the same directory.
  • Modifying the user data directory while Puppeteer or Chrome is running, risking database corruption in Cookies, History, or Web Data files.

Tips

  • Create a backup of your user data directory before starting, especially the Default folder, to prevent data loss.
  • Use environment variables in your Puppeteer script to manage different paths across development machines.
  • Consider using a dedicated testing profile instead of your main Chrome profile to avoid unintended changes.
  • Use Puppeteer’s userDataDir launch option to create temporary shared directories for automated tests.
  • Monitor disk usage—user data directories can grow large with cached data and should be cleaned periodically.

Troubleshooting

If Chrome Canary fails to launch with shared data, first check that no Chrome processes are running in the background. Use Task Manager (Windows), Activity Monitor (macOS), or ps (Linux) to terminate all Chrome-related processes. If the error persists, verify the --user-data-dir path is correct and accessible. Ensure the directory has proper read/write permissions. If Puppeteer throws a crbug error or crashes on startup, it may be due to incompatible profile data between Chrome versions—try launching Canary manually with the same arguments to isolate the issue. If cookies or sessions aren’t shared, confirm that the --profile-directory matches exactly. In some cases, Canary may create a new profile if the directory name is misspelled. Finally, avoid using this setup on shared or public machines due to security risks from exposed session data.

Frequently Asked Questions

Can I use this method to sync extensions?

Yes, extensions installed in the shared profile will be available in both Chrome and Chrome Canary when using the same user data directory.

Will this work if I’m signed into Chrome with a Google account?

Yes, but only the local profile data is shared. Synced data like bookmarks or passwords from your Google account will appear in both if you’re signed in, but the sharing relies on local files.

Can I run Chrome and Chrome Canary at the same time with the same profile?

No. Running both browsers simultaneously with the same user data directory can corrupt profile files. Always close one before launching the other.

Is it safe to share user data between browsers?

It’s safe for personal use if you manage processes carefully, but avoid it on shared systems. Always back up data first.

Does this work with headless mode in Puppeteer?

Yes, but some profile features like extensions may not load in headless mode. Test functionality thoroughly.

What happens if I update Chrome or Chrome Canary?

Updates usually preserve profile data, but major version changes may cause incompatibilities. Always back up before updating.