A VSCode extension template built with Svelte 5, TailwindCSS, and svelte-spa-router for building modern webview-based extensions.
This extension includes two example pages demonstrating VSCode webview API integration:
.
├── src/
│ ├── extension.ts # Extension entry point
│ ├── WebviewProvider.ts # Webview panel provider
│ └── webview/
│ ├── index.ts # Svelte app entry point (mount)
│ ├── index.css # TailwindCSS imports
│ ├── App.svelte # Main app with routing
│ ├── global.d.ts # Type declarations (svelte, css)
│ ├── vscode.d.ts # acquireVsCodeApi() type
│ ├── vscodeApi.ts # VS Code API wrapper
│ └── pages/
│ ├── NotificationPage.svelte
│ └── DirectoryListPage.svelte
├── dist/ # Build output
├── esbuild.js # Build configuration
├── svelte.config.js # Svelte tooling config
├── tailwind.config.js # TailwindCSS configuration
└── postcss.config.js # PostCSS configuration
Install dependencies:
npm install
Build the extension:
npm run compile
Watch for changes:
npm run watch
F5 in VSCode to open a new Extension Development Host windowCmd+Shift+P on Mac, Ctrl+Shift+P on Windows/Linux)Navigate to the "Notification" page and click the button to send a notification to VSCode. This demonstrates:
vscode.window.showInformationMessage()Navigate to the "Directory" page to see the contents of your workspace. This demonstrates:
$state, $effect, $props)npm run compile - Build the extensionnpm run watch - Watch mode for developmentnpm run check-types - Type checking (tsc + svelte-check)npm run lint - Lint the codenpm test - Run testsThe extension uses the VSCode webview messaging API:
From Webview to Extension:
vscode.postMessage({
type: "showNotification",
message: "Hello from Svelte!",
});
From Extension to Webview:
panel.webview.postMessage({
type: "directoryContents",
data: { contents: [...] },
});
.svelte component in src/webview/pages/src/webview/App.svelte (update the routes object)use:linkThe extension uses TailwindCSS v4. All Tailwind utilities are available. The theme uses a dark color scheme optimized for VSCode.
Open Svelte View - Opens the Svelte webview panelHello World - Shows a simple notification (example command)MIT