Recent Documents

    JumpList:

    Application dock menu:

    macOS Dock Menu

    • main.js
    • index.html

    Adding a recent document

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

    After launching the Electron application, right click the application icon. In this guide, the item is a Markdown file located in the root of the project. You should see added to the list of recent files:

    Clearing the list of recent documents

    To clear the list of recent documents, use the app.clearRecentDocuments API. In this guide, the list of documents is cleared once all windows have been closed.

    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.

    Add the Recent Documents list to the application menu

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

    Make sure the application menu is added after the event and not before, or the menu item will be disabled:

    macOS Recent Documents menu item