Set up Vue 3 with TypeScript and type-safe props
✓Works with OpenClaudeYou are a Vue 3 developer setting up a project with full TypeScript support and type-safe component props.
What to check first
- Run
npm create vue@latestand confirm you selected "TypeScript" and "Yes" for JSX/TSX support - Verify
tsconfig.jsonexists in your project root with"strict": true - Check that
vite.config.tsincludesvue()plugin from@vitejs/plugin-vue
Steps
- Install dependencies with
npm installand verifytypescript,vue, and@vue/tsconfigare inpackage.json - Define component props using
defineProps<{ }>with a TypeScript interface inside the angle brackets - Create a separate
.tsfile for shared interfaces to reuse across components (e.g.,types/User.ts) - Use
withDefaults(defineProps<Props>(), { defaultValue: 'value' })to provide default prop values while maintaining type safety - Import the interface in your component and pass it to
defineProps<InterfaceName>() - Add
lang="ts"to the<script setup>tag to enable TypeScript in the component - Use
defineEmits<{ eventName: [payload: PayloadType] }>()for type-safe custom events - Import and use utility types like
Ref<Type>,Computed<Type>fromvuefor ref and computed declarations
Code
<!-- types/User.ts -->
export interface User {
id: number
name: string
email: string
age?: number
}
export interface UserCardProps {
user: User
isActive?: boolean
role: 'admin' | 'user' | 'guest'
}
export interface UserCardEmits {
'update:active': [value: boolean]
'delete-user': [userId: number]
'edit-user': [user: User]
}
<!-- UserCard.vue -->
<script setup lang="ts">
import { computed } from 'vue'
import type { User, UserCardProps, UserCardEmits } from '@/types/User'
const props = withDefaults(defineProps<UserCardProps>(), {
isActive: false,
role: 'user'
})
const emit = defineEmits<UserCardEmits>()
const displayName = computed<string>(() => {
return props.user.name.toUpperCase()
})
const handleDelete = () => {
emit('delete-user', props.user.id)
}
const handleEdit = () => {
emit('edit-user', props.user)
}
const toggleActive = () => {
emit('update:active', !props.isActive)
}
</script>
<template>
<div
class="user-card"
:class="{ active: isActive }"
>
<h
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Vue.js Skills
Other Claude Code skills in the same category — free to download.
Vue Component
Create Vue 3 components with Composition API and props
Vue Pinia
Set up Pinia stores for state management in Vue
Vue Router
Configure Vue Router with navigation guards and dynamic routes
Vue Composable
Build reusable composables for Vue 3
Vue Nuxt
Scaffold Nuxt 3 app with SSR and auto-imports
Vue Testing
Write Vue component tests with Vitest and Testing Library
Vue 3 Composables Pattern
Build reusable composables that share logic across Vue 3 components
Vue Pinia Global State
Manage global app state in Vue 3 with Pinia (modern Vuex replacement)
Want a Vue.js skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.