CursorSvelteGeneral AI
Svelte 5 vs Svelte 4 Rules
I'm using svelte 5 instead of svelte 4 here is an overview of the changes.
.cursorrules
I'm using svelte 5 instead of svelte 4 here is an overview of the changes.
# .cursorrunes for Svelte 5
## Overview of Changes
Svelte 5 introduces runes, a set of advanced primitives for controlling reactivity. The runes replace certain non-runes features and provide more explicit control over state and effects.
Snippets, along with render tags, help create reusable chunks of markup inside your components, reducing duplication and enhancing maintainability.
## Event Handlers in Svelte 5
In Svelte 5, event handlers are treated as standard HTML properties rather than Svelte-specific directives, simplifying their use and integrating them more closely with the rest of the properties in the component.
### Svelte 4 vs. Svelte 5:
**Before (Svelte 4):**
```html
<script>
let count = 0;
$: double = count * 2;
$: {
if (count > 10) alert('Too high!');
}
</script>
<button on:click={() => count++}> {count} / {double}</button>
```
**After (Svelte 5):**
```html
<script>
import { $state, $effect, $derived } from 'svelte';
// Define state with runes
let count = $state(0);
// Option 1: Using $derived for computed values
let double = $derived(count * 2);
// Reactive effects using runes
$effect(() => {How to use with Cursor
Create a `.cursorrules` file in your project root and paste these rules. Cursor reads this automatically on every AI interaction.
#cursor#svelte#ai-coding-rules
Related Rules
Python Cursor Rules
CursorPython
Best Cursor AI coding rules for Python development. Enforce type hints, PEP 8, Pythonic patterns, and modern Python best practices in your .cursorrules file.
Code Style
python · type-hintsCopy Ready
TypeScript Cursor Rules
CursorTypeScript
Cursor rules for TypeScript: enforce strict mode, eliminate any types, and write type-safe code with these .cursorrules configurations.
Code Style
typescript · strictCopy Ready
React Cursor Rules
CursorReact
Cursor rules for React: component patterns, hooks best practices, performance optimization, and clean state management conventions.
Architecture
react · hooksCopy Ready
Next.js Cursor Rules
CursorNext.js
Cursor rules for Next.js App Router: server components, data fetching, routing, and deployment best practices.
Architecture
nextjs · app-routerCopy Ready