mirror of https://github.com/sveltejs/svelte
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
changeset-release/main
main
error-boundaries
migrate-conflict-runes
props-binding-fix
gh-14111-alternative
warning-message
title-removal-fix
warning
update-store-docs
svelte-4
revert-13651-compile-warning
disclaimer
transition-out-effect-tracking
cleanup-non-render-effects-in-blocks
annotate-notes
fix-nullish-actions
migrate-svelte-component
fix-parse-type
css-migrate-blank
fix-import-run-space
gh-13270
gh-13256
table-td-autoopen
simpler-process-effects
better-docs-for-css-injected
revert-13158-valid-ssr
derived-by-current-value
custom-formatter
gh-12624
omit-trailing-sibling-calls
gh-12084
state-link-fix
readonly-props
gh-12896
safari-borking-2
benmccann-patch-1
migrate-member-assignment
animation-params
feat/support-modern-ast-flag-on-repl
nolyfill
svelte-5-docs-proposal-wip
fix-memory-leak-
chore/bump-deps
snippet-work-cont
new-spring
effect-active-derived-allow-unowned
runes-in-constructor
some-cleanup
fix-playground
better-snapshot
object-freeze-fix
context-ownership
props-bindable
effect-docs-2
blockless
remove-readonly-check
ttf-fix
remove-ttf-hack
derived-consumer-fix
compile-return-ast
rm-bytes
hoist-unmodified-var
puru/try-jsdelivr
benmccann-patch-2
elliott/add-variadic-snippets
proxied-state-set
dynamic-component-types
proxied-state-each-blocks
baseballyama-docs/string-event
tidy-up-analysis
svelte-4-base
fix-symlink
quicker-redirects
introducing-runes
versioned-docs
raw-hydration-mismatch
fix-stale-await-ctx
parse-regexp-no-paren
fix-dyn-component-test
ce-tick
feat/orama
parser-let-destructure
version-3
sites-examples
gh-3780
v2
svelte@5.1.12
svelte@5.1.11
svelte@5.1.10
svelte@5.1.9
svelte@5.1.8
svelte@5.1.7
svelte@5.1.6
svelte@5.1.5
svelte@5.1.4
svelte@5.1.3
svelte@5.1.2
svelte@5.1.1
svelte@5.1.0
svelte@5.0.5
svelte@5.0.4
svelte@5.0.3
svelte@5.0.2
svelte@5.0.1
svelte@5.0.0
svelte@5.0.0-next.272
svelte@5.0.0-next.271
svelte@5.0.0-next.270
svelte@5.0.0-next.269
svelte@5.0.0-next.268
svelte@5.0.0-next.267
svelte@5.0.0-next.266
svelte@5.0.0-next.265
svelte@5.0.0-next.264
svelte@5.0.0-next.263
svelte@5.0.0-next.262
svelte@5.0.0-next.260
svelte@5.0.0-next.259
svelte@5.0.0-next.258
svelte@5.0.0-next.257
svelte@5.0.0-next.256
svelte@5.0.0-next.255
svelte@5.0.0-next.254
svelte@5.0.0-next.253
svelte@5.0.0-next.252
svelte@5.0.0-next.251
svelte@5.0.0-next.250
svelte@5.0.0-next.249
svelte@5.0.0-next.248
svelte@5.0.0-next.247
svelte@5.0.0-next.246
svelte@5.0.0-next.245
svelte@5.0.0-next.244
svelte@5.0.0-next.243
svelte@5.0.0-next.242
svelte@5.0.0-next.241
svelte@5.0.0-next.240
svelte@5.0.0-next.239
svelte@5.0.0-next.238
svelte@5.0.0-next.237
svelte@5.0.0-next.236
svelte@4.2.19
svelte@5.0.0-next.235
svelte@5.0.0-next.234
svelte@5.0.0-next.233
svelte@5.0.0-next.232
svelte@5.0.0-next.231
svelte@5.0.0-next.230
svelte@5.0.0-next.229
svelte@5.0.0-next.228
svelte@5.0.0-next.227
svelte@5.0.0-next.226
svelte@5.0.0-next.225
svelte@5.0.0-next.224
svelte@5.0.0-next.223
svelte@5.0.0-next.222
svelte@5.0.0-next.221
svelte@5.0.0-next.220
svelte@5.0.0-next.219
svelte@5.0.0-next.218
svelte@5.0.0-next.217
svelte@5.0.0-next.216
svelte@5.0.0-next.215
svelte@5.0.0-next.214
svelte@5.0.0-next.213
svelte@5.0.0-next.212
svelte@5.0.0-next.211
svelte@5.0.0-next.210
svelte@5.0.0-next.208
svelte@5.0.0-next.207
svelte@5.0.0-next.206
svelte@5.0.0-next.205
svelte@5.0.0-next.204
svelte@5.0.0-next.203
svelte@5.0.0-next.202
svelte@5.0.0-next.201
svelte@5.0.0-next.200
svelte@5.0.0-next.199
svelte@5.0.0-next.198
svelte@5.0.0-next.197
svelte@5.0.0-next.196
svelte@5.0.0-next.195
svelte@5.0.0-next.194
svelte@5.0.0-next.193
svelte@5.0.0-next.192
svelte@5.0.0-next.191
svelte@5.0.0-next.190
svelte@5.0.0-next.189
svelte@5.0.0-next.188
svelte@5.0.0-next.187
svelte@5.0.0-next.186
svelte@5.0.0-next.185
svelte@5.0.0-next.184
svelte@5.0.0-next.183
svelte@5.0.0-next.182
svelte@5.0.0-next.181
svelte@5.0.0-next.180
svelte@5.0.0-next.179
svelte@5.0.0-next.178
svelte@5.0.0-next.177
svelte@5.0.0-next.176
svelte@5.0.0-next.175
svelte@5.0.0-next.174
svelte@5.0.0-next.173
svelte@5.0.0-next.172
svelte@5.0.0-next.171
svelte@5.0.0-next.170
svelte@5.0.0-next.169
svelte@5.0.0-next.168
svelte@5.0.0-next.167
svelte@5.0.0-next.166
svelte@5.0.0-next.165
svelte@5.0.0-next.164
svelte@5.0.0-next.163
svelte@5.0.0-next.160
svelte@5.0.0-next.159
svelte@5.0.0-next.158
svelte@5.0.0-next.157
svelte@5.0.0-next.155
svelte@5.0.0-next.154
svelte@5.0.0-next.153
svelte@5.0.0-next.152
svelte@5.0.0-next.151
svelte@4.2.18
svelte@5.0.0-next.150
svelte@5.0.0-next.149
svelte@5.0.0-next.148
svelte@5.0.0-next.147
svelte@5.0.0-next.144
svelte@5.0.0-next.143
svelte@5.0.0-next.142
svelte@5.0.0-next.141
svelte@5.0.0-next.140
svelte@5.0.0-next.139
svelte@5.0.0-next.138
svelte@5.0.0-next.137
svelte@5.0.0-next.136
svelte@5.0.0-next.135
svelte@5.0.0-next.134
svelte@5.0.0-next.133
svelte@5.0.0-next.132
svelte@4.2.17
svelte@5.0.0-next.131
svelte@5.0.0-next.130
svelte@5.0.0-next.129
svelte@5.0.0-next.128
svelte@5.0.0-next.127
svelte@5.0.0-next.126
svelte@5.0.0-next.125
svelte@4.2.16
svelte@5.0.0-next.123
svelte@5.0.0-next.121
svelte@5.0.0-next.120
svelte@5.0.0-next.119
svelte@5.0.0-next.118
svelte@5.0.0-next.117
svelte@5.0.0-next.116
svelte@5.0.0-next.115
svelte@5.0.0-next.114
svelte@5.0.0-next.113
svelte@5.0.0-next.112
svelte@5.0.0-next.111
svelte@5.0.0-next.110
svelte@5.0.0-next.109
svelte@5.0.0-next.108
svelte@4.2.15
svelte@5.0.0-next.107
svelte@5.0.0-next.106
svelte@5.0.0-next.105
svelte@5.0.0-next.104
svelte@5.0.0-next.103
svelte@5.0.0-next.102
svelte@4.2.14
svelte@5.0.0-next.101
svelte@5.0.0-next.100
svelte@5.0.0-next.99
svelte@5.0.0-next.98
svelte@5.0.0-next.97
svelte@4.2.13
svelte@5.0.0-next.96
svelte@5.0.0-next.95
svelte@5.0.0-next.94
svelte@5.0.0-next.93
svelte@5.0.0-next.92
svelte@5.0.0-next.91
svelte@5.0.0-next.90
svelte@5.0.0-next.89
svelte@5.0.0-next.88
svelte@5.0.0-next.87
svelte@5.0.0-next.86
svelte@5.0.0-next.85
svelte@5.0.0-next.84
svelte@5.0.0-next.83
svelte@5.0.0-next.82
svelte@5.0.0-next.81
svelte@5.0.0-next.80
svelte@5.0.0-next.79
svelte@5.0.0-next.78
svelte@5.0.0-next.77
svelte@5.0.0-next.76
svelte@5.0.0-next.75
svelte@5.0.0-next.74
svelte@5.0.0-next.73
svelte@5.0.0-next.72
svelte@5.0.0-next.71
svelte@5.0.0-next.70
svelte@5.0.0-next.69
svelte@5.0.0-next.68
svelte@5.0.0-next.67
svelte@5.0.0-next.66
svelte@4.2.12
svelte@5.0.0-next.65
svelte@5.0.0-next.64
svelte@5.0.0-next.63
svelte@5.0.0-next.62
svelte@5.0.0-next.61
svelte@5.0.0-next.60
svelte@5.0.0-next.59
svelte@5.0.0-next.58
svelte@5.0.0-next.57
svelte@5.0.0-next.56
svelte@5.0.0-next.55
svelte@4.2.11
svelte@5.0.0-next.54
svelte@5.0.0-next.53
svelte@5.0.0-next.52
svelte@5.0.0-next.51
svelte@5.0.0-next.50
svelte@5.0.0-next.49
svelte@5.0.0-next.48
svelte@5.0.0-next.47
svelte@4.2.10
svelte@5.0.0-next.46
svelte@5.0.0-next.45
svelte@5.0.0-next.44
svelte@5.0.0-next.43
svelte@5.0.0-next.42
svelte@5.0.0-next.41
svelte@5.0.0-next.40
svelte@5.0.0-next.39
svelte@5.0.0-next.38
svelte@5.0.0-next.37
svelte@4.2.9
svelte@5.0.0-next.36
svelte@5.0.0-next.35
svelte@5.0.0-next.34
svelte@5.0.0-next.33
svelte@5.0.0-next.32
svelte@5.0.0-next.31
svelte@5.0.0-next.30
svelte@5.0.0-next.29
svelte@5.0.0-next.28
svelte@5.0.0-next.27
svelte@5.0.0-next.26
svelte@5.0.0-next.25
svelte@5.0.0-next.24
svelte@5.0.0-next.23
svelte@5.0.0-next.22
svelte@5.0.0-next.21
svelte@5.0.0-next.20
svelte@5.0.0-next.19
svelte@5.0.0-next.18
svelte@5.0.0-next.17
svelte@5.0.0-next.16
svelte@4.2.8
svelte@5.0.0-next.15
svelte@5.0.0-next.14
svelte@5.0.0-next.13
svelte@5.0.0-next.12
svelte@5.0.0-next.11
svelte@5.0.0-next.10
svelte@5.0.0-next.9
svelte@4.2.7
svelte@4.2.6
svelte@5.0.0-next.8
svelte@5.0.0-next.7
svelte@5.0.0-next.6
svelte@5.0.0-next.5
svelte@4.2.5
svelte@4.2.4
svelte@5.0.0-next.4
svelte@5.0.0-next.3
svelte@5.0.0-next.2
svelte@5.0.0-next.1
svelte@4.2.3
svelte@4.2.2
svelte@4.2.1
svelte@4.2.0
svelte@4.1.2
svelte@4.1.1
svelte@4.1.0
svelte@4.0.5
svelte@4.0.4
svelte@4.0.3
svelte@4.0.2
svelte@4.0.1
svelte@4.0.0
svelte@4.0.0-next.3
v3.59.2
svelte@4.0.0-next.1
svelte@4.0.0-next.0
v3.59.1
v3.59.0
v3.58.0
v3.57.0
v3.56.0
v3.55.1
v3.55.0
v3.54.0
v3.53.1
v3.53.0
v3.52.0
v3.51.0
v3.50.1
v3.50.0
v3.49.0
v3.48.0
v3.47.0
v3.46.6
v3.46.5
v3.46.4
v3.46.3
v3.46.2
v3.46.1
v3.46.0
v3.45.0
v3.44.3
v3.44.2
v3.44.1
v3.44.0
v3.43.2
v3.43.1
v3.43.0
v3.42.6
v3.42.5
v3.42.4
v3.42.3
v3.42.2
v3.42.1
v3.42.0
v3.41.0
v3.40.3
v3.40.2
v3.40.1
v3.40.0
v3.39.0
v3.38.3
v3.38.2
v3.38.1
v3.38.0
v3.37.0
v3.36.0
v3.35.0
v3.34.0
v3.33.0
v3.32.3
v3.32.2
v3.32.1
v3.32.0
v3.31.2
v3.31.1
v3.31.0
v3.30.1
v3.30.0
v3.29.7
v3.29.6
v3.29.5
v3.29.4
v3.29.3
v3.29.2
v3.29.1
v3.29.0
v3.28.0
v3.27.0
v3.26.0
v3.25.1
v3.25.0
v3.24.1
v3.24.0
v3.23.2
v3.23.1
v3.23.0
v3.22.3
v3.22.2
v3.22.1
v3.22.0
v3.21.0
v3.20.1
v3.20.0
v3.19.2
v3.19.1
v3.19.0
v3.18.2
v3.18.1
v3.18.0
v3.17.3
v3.17.2
v3.17.1
v3.17.0
v3.16.7
v3.16.6
v3.16.5
v3.16.4
v3.16.3
v3.16.2
v3.16.1
v3.16.0
v3.15.0
v3.14.1
v3.14.0
v3.13.0
v3.12.1
v3.12.0
v3.11.0
v3.10.1
v3.10.0
v3.9.2
v3.9.1
v3.9.0
v3.8.1
v3.8.0
v3.7.1
v3.7.0
v3.6.11
v3.6.10
v3.6.9
v3.6.8
v3.6.7
v3.6.6
v3.6.5
v3.6.4
v3.6.3
v3.6.2
v3.6.1
v3.6.0
v3.5.4
v3.5.3
v3.5.2
v3.5.1
v3.5.0
v3.4.4
v3.4.3
v3.4.2
v3.4.1
v3.4.0
v3.3.0
v3.2.2
v3.2.1
v3.2.0
v3.1.0
v3.0.1
v3.0.0
v3.0.0-beta.24
v2.16.1
v2.16.0
v2.15.4
v2.15.3
v2.15.2
v2.15.1
v2.15.0
v2.14.3
v2.14.2
v2.14.1
v2.14.0
v2.13.5
v2.13.4
v2.13.3
v2.13.2
v2.13.1
v2.13.0
v2.12.1
v2.12.0
v2.11.0
v2.10.1
v2.10.0
v2.9.11
v2.9.10
v2.9.9
v2.9.8
v2.9.7
v2.9.6
v2.9.5
v2.9.4
v2.9.3
v2.9.2
v2.9.1
v2.9.0
v2.8.1
v2.8.0
v2.7.2
v2.7.1
v2.7.0
v2.6.6
v2.6.5
v2.6.4
v2.6.3
v2.6.2
v2.6.1
v2.6.0
v2.5.1
v2.5.0
v2.4.4
v2.4.3
v2.4.2
v2.4.1
v2.4.0
v2.3.0
v2.2.0
v2.1.1
v2.1.0
v2.0.0
v1.64.1
v1.64.0
v1.63.1
v1.63.0
v1.62.0
v1.61.0
v1.60.3
v1.60.2
v1.60.1
v1.60.0
v1.59.0
v1.58.5
v1.58.4
v1.58.3
v1.58.2
v1.58.1
v1.58.0
v1.57.4
v1.57.3
v1.57.2
v1.57.1
v1.57.0
v1.56.4
v1.56.3
v1.56.2
v1.56.1
v1.56.0
v1.55.1
v1.55.0
v1.54.2
v1.54.1
v1.54.0
v1.53.0
v1.52.0
v1.51.1
v1.51.0
v1.50.1
v1.50.0
v1.49.3
v1.49.2
v1.49.1
v1.49.0
v1.48.0
v1.47.2
v1.47.1
v1.47.0
v1.46.1
v1.46.0
v1.45.0
v1.44.2
v1.44.1
v1.44.0
v1.43.1
v1.43.0
v1.42.1
v1.42.0
v1.41.4
v1.41.3
v1.41.2
v1.41.1
v1.41.0
v1.40.2
v1.40.1
v1.40.0
v1.39.4
v1.39.3
v1.39.2
v1.39.1
v1.39.0
v1.38.0
v1.37.0
v1.36.0
v1.35.0
v1.34.0
v1.33.0
v1.32.0
v1.31.0
v1.30.0
v1.29.3
v1.29.2
v1.29.1
v1.29.0
v1.28.1
v1.28.0
v1.27.0
v1.26.2
v1.26.1
v1.26.0
v1.25.1
v1.25.0
v1.24.0
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.21.0
v1.20.2
v1.20.1
v1.20.0
v1.19.1
v1.19.0
v1.18.2
v1.18.1
v1.18.0
v1.17.2
v1.17.1
v1.17.0
v1.16.0
v1.15.1
v1.15.0
v1.14.1
v1.14.0
v1.13.7
v1.13.6
v1.13.5
v1.13.4
v1.13.3
v1.13.2
v1.13.1
v1.13.0
v1.12.1
v1.12.0
v1.11.4
v1.11.3
v1.11.2
v1.11.1
v1.11.0
v1.10.2
v1.10.1
v1.10.0
v1.9.1
v1.9.0
v1.8.1
v1.8.0
v1.7.1
v1.7.0
v1.6.11
v1.6.10
v1.6.9
v1.6.8
v1.6.7
v1.6.6
v1.6.5
v1.6.4
v1.6.3
v1.6.2
v1.6.1
v1.6.0
v1.5.0
v1.4.0
v1.3.1
v1.3.0
v1.2.5
v1.2.4
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.7
v1.0.6
v1.0.5
v1.0.4
v1.0.3
v1.0.2
v1.0.1
v1.0.0
v0.3.0
v0.2.2
v0.2.1
v0.2.0
v0.1.1
v0.1.0
v0.0.2
${ noResults }
33 lines
2.1 KiB
33 lines
2.1 KiB
---
|
|
title: Basics
|
|
---
|
|
|
|
Welcome to the Svelte tutorial. This will teach you everything you need to know to build fast, small web applications easily.
|
|
|
|
You can also consult the [API docs](docs) and the [examples](examples), or — if you're impatient to start hacking on your machine locally — the [60-second quickstart](blog/the-easiest-way-to-get-started).
|
|
|
|
|
|
## What is Svelte?
|
|
|
|
Svelte is a tool for building fast web applications.
|
|
|
|
It is similar to JavaScript frameworks such as React and Vue, which share a goal of making it easy to build slick interactive user interfaces.
|
|
|
|
But there's a crucial difference: Svelte converts your app into ideal JavaScript at *build time*, rather than interpreting your application code at *run time*. This means you don't pay the performance cost of the framework's abstractions, and you don't incur a penalty when your app first loads.
|
|
|
|
You can build your entire app with Svelte, or you can add it incrementally to an existing codebase. You can also ship components as standalone packages that work anywhere, without the overhead of a dependency on a conventional framework.
|
|
|
|
|
|
## How to use this tutorial
|
|
|
|
You'll need to have basic familiarity with HTML, CSS and JavaScript to understand Svelte.
|
|
|
|
As you progress through the tutorial, you'll be presented with mini exercises designed to illustrate new features. Later chapters build on the knowledge gained in earlier ones, so it's recommended that you go from start to finish. If necessary, you can navigate via the dropdown above (click 'Introduction / Basics').
|
|
|
|
Each tutorial chapter will have a 'Show me' button that you can click if you get stuck following the instructions. Try not to rely on it too much; you will learn faster by figuring out where to put each suggested code block and manually typing it in to the editor.
|
|
|
|
|
|
## Understanding components
|
|
|
|
In Svelte, an application is composed from one or more *components*. A component is a reusable self-contained block of code that encapsulates HTML, CSS and JavaScript that belong together, written into a `.svelte` file. The 'hello world' example in the code editor is a simple component.
|