Black Lives Matter. Support the Equal Justice Initiative and read our statement here.

Electron Documentation

Recent Documents (Windows & macOS)

Windows and macOS provide access to a list of recent documents opened by the application via JumpList or dock menu, respectively.


JumpList Recent Files

Application dock menu:

macOS Dock Menu

To add a file to recent documents, you can use the app.addRecentDocument API:

const { app } = require('electron')

And you can use app.clearRecentDocuments API to empty the recent documents list:

const { app } = require('electron')

Windows Notes

In order to be able to use this feature on Windows, your application has to be registered as a handler of the file type of the document, otherwise the file won't appear in JumpList even after you have added it. You can find everything on registering your application in Application Registration.

When a user clicks a file from the JumpList, a new instance of your application will be started with the path of the file added as a command line argument.

Adding the Recent Documents list to the application menu:

macOS Recent Documents menu item

You can add menu items to access and clear recent documents by adding the following code snippet to your menu's template.

      "label":"Open Recent",
          "label":"Clear Recent",

When a file is requested from the recent documents menu, the open-file event of app module will be emitted for it.

Keyboard Shortcuts

Key Action
/ Focus the search bar
Esc Focus the search bar and cleans it
Select the next search result
Select the previous search result
Enter Open the selected search result
cmdEnter Ctrl+Enter Open the selected search result in a new tab