Home › All rules › Community › Svelte Cursor Rules

Svelte Cursor Rules

Svelte best practices and patterns for modern web applications

CursorSvelteKitCommunity (CC0)

How to use

Save this as .cursor/rules/svelte.mdc in your project, commit it, and Cursor will load it. Review it first: community files can be opinionated or out of date.

Note: Review and test before use. Provided as is, without warranty. See Terms.

.cursor/rules/svelte.mdcDownload  
---
description: "Svelte best practices and patterns for modern web applications"
globs: **/*.svelte, src/**/*.ts, src/**/*.js
alwaysApply: false
---
# Svelte Best Practices

## Component Structure
- Keep components small and focused
- Use proper TypeScript integration
- Implement proper props typing
- Use proper event dispatching
- Keep markup clean and readable
- Use proper slot implementation

## Reactivity
- Use proper reactive declarations
- Implement proper stores
- Use proper reactive statements
- Handle derived values properly
- Use proper lifecycle functions
- Implement proper bindings

## State Management
- Use proper Svelte stores
- Keep stores modular
- Use proper derived stores
- Implement proper actions
- Handle async state properly
- Use proper store subscriptions

## Performance
- Use proper component lazy loading
- Implement proper transitions
- Use proper animations
- Avoid unnecessary reactivity
- Use proper event forwarding
- Implement proper key blocks

## Routing
- Use SvelteKit for routing
- Implement proper layouts
- Use proper route parameters
- Handle loading states properly
- Implement proper error pages
- Use proper navigation methods

## Forms
- Use proper form bindings
- Implement proper validation
- Handle form submission properly
- Show proper loading states
- Use proper error handling
- Implement proper form reset

## TypeScript Integration
- Use proper component types
- Implement proper prop types
- Use proper event types
- Handle proper type inference
- Use proper store types
- Implement proper action types

## Testing
- Write proper unit tests
- Implement proper component tests
- Use proper testing libraries
- Test stores properly
- Implement proper mocking
- Test async operations

## Best Practices
- Follow Svelte style guide
- Use proper naming conventions
- Keep components organized
- Implement proper error handling
- Use proper event handling
- Document complex logic

## Build and Tooling
- Use Vite for development
- Configure proper build setup
- Use proper environment variables
- Implement proper code splitting
- Use proper asset handling
- Configure proper optimization

More: SvelteKit rules · all community rules

Related rules

Svelte 5 runes Windsurf rules

Windsurf rules for Svelte 5 components with runes ($state, $derived, $props) in SvelteKit 2 apps.

WindsurfSvelteKit

SvelteKit AGENTS.md

AGENTS.md for SvelteKit 2 + Svelte 5 (runes) apps with TypeScript.

AGENTS.mdSvelteKit

Svelte 5 Vs Svelte 4 Cursor Rules

Cursor rules for comparing Svelte 5 and Svelte 4 development.

CursorSvelteKitCommunity (CC0)

Sveltekit Restful Api Tailwind Css Cursor Rules

Cursor rules for SvelteKit development with RESTful API and Tailwind CSS integration.

CursorSvelteKitCommunity (CC0)

Sveltekit Tailwindcss TypeScript Cursor Rules

Cursor rules for SvelteKit development with Tailwind CSS and TypeScript integration.

CursorSvelteKitCommunity (CC0)

Sveltekit TypeScript Guide Cursor Rules

Cursor rules for SvelteKit development with TypeScript integration.

CursorSvelteKitCommunity (CC0)

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.