Get Obsidian URL action

When I type this url to browser (obsidian://clickup?code=testingxcode) and open Obsidian with it, in Obsidian devtools console logs this: Received URL action: {action: ‘clickup’, code: ‘testingxcode’; but, how can i get this data in my custom Obsidian plugin? This log comes from app.js.

Check the docs for registerObsidianProtocolHandler here:

Here is an example I use in one of my plugins:

 async onload() {
  // ...
  
  this.registerObsidianProtocolHandler("playground", async (e) => {
    const parameters = e as unknown as Parameters;
    const f = this.app.vault.getAbstractFileByPath(parameters.tplPath!);
    if (f instanceof TFile) {
      this.settings.template = f;
      await this.saveSettings();
      await this.activateView();
    }
  });

  // ...
}

Here is an example URL that activates this handler:

obsidian://playground?vault=Playground&tplPath=Atlas%2FUtilities%2FPlaygrounds%2F___New%20Blank%20Project.json

2 Likes

Thanks a lot! It works!