# Server Integrations Lune is designed from the ground up for progressive enhancement. It's most powerful when used alongside server-side frameworks like Astro, Django, Laravel, Rails, or ASP.NET. Instead of building a Single Page Application (SPA), you can keep your routing, authentication, and primary data fetching on the server and use Lune to "sprinkle" interactivity where it's needed. ## Core Integration Patterns ### 1. Initial State Injection The most common pattern is injecting initial state directly into `lu-scope` during the server-side render. ```html

Hello, {{ user.name }}

``` ### 2. Handling CSRF Tokens Any AJAX requests made from Lune must include a CSRF token. **Option 1: Read from Meta Tag (Recommended)** ```js const getToken = () => document.querySelector('meta[name="csrf-token"]').content; function submit() { fetch("/api/save", { method: "POST", headers: { "X-CSRF-TOKEN": getToken(), "Content-Type": "application/json" }, body: JSON.stringify(this.formData) }); } ``` ### 3. Progressive Enhancement Design your features to work without JavaScript first, then enhance them with Lune. ```html
``` > [!IMPORTANT] > The handler has to live on the scope. A function declared in a `