src/main.ts
import { mount } from 'svelte'
import App from './App.svelte'
import './styles.css'
const target = document.getElementById('app')
if (!target) {
throw new Error('App target was not found')
}
mount(App, { target })
Online Svelte playground with live preview, reactive components, and Svelte syntax. Build and test Svelte applications directly in your browser.
Choose a source file from the explorer and edit it with Monaco.
Edit package.json to add browser-compatible npm packages or change versions. Preview packages load from esm.sh. Successful previews save resolved versions for ranges and tags with your draft and shares; change the range to resolve again. Scripts and build plugins run only in downloaded projects.
Auto-run updates the browser preview as you type. Turn it off to run your changes manually.
Use the console for browser logs and errors, or evaluate a command against the preview.
Share creates a snapshot link. Download exports the source so you can continue locally.
import { mount } from 'svelte'
import App from './App.svelte'
import './styles.css'
const target = document.getElementById('app')
if (!target) {
throw new Error('App target was not found')
}
mount(App, { target })
<script lang="ts">
import CounterCard from './components/CounterCard.svelte'
let count = $state(0)
</script>
<main class="app-shell">
<p class="eyebrow">Svelte 5 · Runes + TypeScript</p>
<h1>Build with real .svelte files</h1>
<p class="intro">
This playground compiles runes, TypeScript, scoped styles, and local
component imports directly in your browser.
</p>
<CounterCard {count} onIncrement={() => count += 1} />
</main>
<style>
.app-shell {
width: min(680px, calc(100% - 2rem));
margin: 0 auto;
padding: 5rem 0;
}
.eyebrow {
margin: 0 0 0.75rem;
color: #c83200;
font-size: 0.75rem;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
h1 {
margin: 0;
color: #3b2018;
font-size: clamp(2.25rem, 7vw, 4.5rem);
line-height: 0.98;
letter-spacing: -0.055em;
}
.intro {
max-width: 58ch;
margin: 1.25rem 0 2rem;
color: #765f58;
line-height: 1.7;
}
</style>
The editor uses Monaco, the engine behind VS Code, with language-aware editing tools and familiar keyboard controls.
Edit a source file from the project explorer — the live preview recompiles automatically.
Add, rename, duplicate or delete project files as needed. Update affected imports after renaming or moving a file.
Use the console for logs and errors, and Format to tidy the active file.
Share the complete project or download a Vite project ZIP with its source files and package.json.
Svelte Components
Reactive Statements
Template Syntax
Live Preview
Event Handling
State Management
Svelte Stores
Auto-run updates the preview as you type. Turn it off to run manually with Run or Ctrl/⌘ + Enter.
The Console prompt can inspect browser globals and the rendered DOM, but not variables scoped inside ES modules or component state.
Console shortcuts apply when its prompt is focused. Editor shortcuts apply inside the code editor.
Code runs in a sandboxed browser preview, without Node.js, a backend, or private environment variables.
Download the project when you need build plugins, server APIs, native modules, or a production dependency workflow.