---
name: script-setup
description: Teaches Vue's script setup syntax for concise Composition API usage. Use when writing Vue 3 single-file components and you want a more ergonomic, less boilerplate syntax for the Composition API.
paths:
- "**/*.vue"
license: MIT
metadata:
author: patterns.dev
version: "1.1"
related_skills:
- "composables"
- "components"
---
# `
```
`` contains the component's markup in plain HTML, `
```
> Be sure to read the [Composables](/vue/composables) guide for a deeper-dive into the advantages the Composition API provides over the traditional Options API syntax.
### `
```
Let's explore some of the main differences in syntax the `
```
#### After
```html
Count: {{ count }}
Username: {{ state.username }}
```
#### No locally registered components
Component imports are automatically recognized and resolved within the `
```
#### After
```html
```
#### `defineProps()`
Props can be accessed directly within the `
```
#### After
```html
```
`defineProps()` also allows us to declare the shape of our props with pure TypeScript.
```html
```
To provide default prop values in the type-only declaration we have above, we can use the `withDefaults()` compiler macro to achieve this.
```html
```
`defineProps` is available only in `
```
#### After
```html
```
Like `defineProps`, `defineEmits` is a special keyword available only in `
```
### `