# How do you attach a view to the sidebar? #obsidian/api/faq --- ## Sample Code ```ts // Create a new View of type `my-view-type` and adds it to the right sidebar // (use `getLeftLeaf` for the left sidebar) this.app.workspace.getRightLeaf(false).setViewState({ type: 'my-view-type', }); ```