One automatically optimizes CSS loading in production builds. Layout CSS is loaded before scripts to prevent flash of unstyled content (FOUC), and you can mark individual CSS files as inline to embed them directly into the HTML.
In production builds, One separates CSS into two categories:
_layout files. Loaded before any JavaScript to prevent FOUC.This happens automatically based on your route structure. No configuration needed.
.inline.css)For CSS that must be available before the first paint, use the .inline.css file extension. This inlines the CSS content directly as a <style> tag in the HTML <head>, eliminating the network request entirely.
app/_layout.tsx
// inlined as <style> in HTML — zero network latency
import './critical-styles.inline.css'
// loaded via <link> tag — normal network request
import './non-critical-styles.css'
.inline.cssUse .inline.css for CSS that:
Don’t use .inline.css for:
<link>).inline.css extension is detected during the build — Vite processes the CSS normally<style> tags<link rel="stylesheet"> tagsinlineLayoutCSS.inline.css works independently of the inlineLayoutCSS config option:
inlineLayoutCSS: true — inlines ALL CSS as <style> tags.inline.css — inlines only the marked files, leaves the rest as <link> tagsinlineLayoutCSS takes precedence and inlines everythingThe .inline.css extension works with any CSS file. Since it’s a side-effect import (no default export), TypeScript handles it without additional type declarations:
import './styles.inline.css' // works out of the box
| Approach | What it does | Use case |
|---|---|---|
| Default | Layout CSS before scripts, page CSS after | Most apps |
.inline.css | Specific files inlined as <style> | Above-the-fold CSS |
inlineLayoutCSS: true | All CSS inlined as <style> | Small apps, maximum LCP |
Edit this page on GitHub.