Skip to content

useLightningcss

This feature is currently experimental and subject to change, it's not recommended for production. Try it out and share your feedback on GitHub.
Last updated March 11, 2026

Experimental support for using Lightning CSS with webpack. Lightning CSS is a fast CSS transformer and minifier, written in Rust.

If this option is not set, Next.js on webpack uses PostCSS with postcss-preset-env by default.

Turbopack uses Lightning CSS by default since Next 14.2. This configuration option has no effect on Turbopack. Turbopack always uses Lightning CSS.

next.config.ts
import type { NextConfig } from 'next'
 
const nextConfig: NextConfig = {
  experimental: {
    useLightningcss: false, // default, ignored on Turbopack
  },
}
 
export default nextConfig

lightningCssFeatures

By default, Lightning CSS decides which CSS features to transpile based on your browserslist targets. The lightningCssFeatures option lets you override this by forcing specific features to always be transpiled (include) or never be transpiled (exclude), regardless of browser support.

This applies to both webpack (when useLightningcss is enabled) and Turbopack.

next.config.ts
import type { NextConfig } from 'next'
 
const nextConfig: NextConfig = {
  experimental: {
    useLightningcss: true,
    lightningCssFeatures: {
      // Always transpile these features, even if targets support them
      include: ['light-dark', 'oklab-colors'],
      // Never transpile these features, even if targets don't support them
      exclude: ['nesting'],
    },
  },
}
 
export default nextConfig

Options

OptionTypeDescription
includestring[]Features to always transpile, regardless of browser targets.
excludestring[]Features to never transpile, even when browser targets would require them.

Available features

Individual features:

Feature nameDescription
nestingCSS Nesting
not-selector-list:not with multiple selectors
dir-selector:dir() selector
lang-selector-list:lang() with multiple languages
is-selector:is() selector
text-decoration-thickness-percentPercentage values in text-decoration-thickness
media-interval-syntaxMedia query range interval syntax
media-range-syntaxMedia query range syntax (width >= 600px)
custom-media-queries@custom-media rules
clamp-functionclamp() function
color-functioncolor() function
oklab-colorsoklab() and oklch() colors
lab-colorslab() and lch() colors
p3-colorsDisplay P3 colors
hex-alpha-colors4 and 8 digit hex colors with alpha
space-separated-color-notationSpace-separated color notation (rgb(0 0 0))
font-family-system-uisystem-ui font family
double-position-gradientsDouble-position gradient stops
vendor-prefixesVendor-prefixed properties and values
logical-propertiesLogical properties and values
light-darklight-dark() color function

Composite groups (shorthand for enabling multiple features at once):

Group nameIncludes
selectorsnesting, not-selector-list, dir-selector, lang-selector-list, is-selector
media-queriesmedia-interval-syntax, media-range-syntax, custom-media-queries
colorscolor-function, oklab-colors, lab-colors, p3-colors, hex-alpha-colors, space-separated-color-notation, light-dark

Version History

VersionChanges
16.2.0lightningCssFeatures added.
15.1.0Support for useSwcCss was removed from Turbopack.
14.2.0Turbopack's default CSS processor was changed from @swc/css to Lightning CSS. useLightningcss became ignored on Turbopack, and a legacy experimental.turbo.useSwcCss option was added.

Was this helpful?

supported.