Vanilla CSS syntax in TypeScript, zero runtime. CSS-in-JS for React and Solid with the styled-components API, compiled to plain CSS at build time by a Rust SWC plugin.
Vanilla CSS syntax in TypeScript, with zero runtime. yak is CSS-in-JS for React and Solid with the styled-components API: a Rust SWC plugin compiles your styles to plain CSS files at build time, so it works with React Server Components and ships no styling runtime to the browser.
Documentation · Playground · Blog
Formerly next-yak. Same library, same team. From version 10 the React package is
@yak/react, and versions before 10 stay on npm asnext-yak. Runnpx next-yak migrateto switch, and see the migration guide for the details.
yak runs in production at Digitec Galaxus, the largest e-commerce platform in Switzerland, across thousands of styled components, and measurably improved its Core Web Vitals there.
| Package | Version | What it is |
|---|---|---|
@yak/react | yak for React, with plugins for Next.js, Vite and Rsbuild | |
@yak/solid | yak for Solid 2, with a Vite plugin (experimental) | |
@yak/swc | the Rust SWC plugin that both runtimes use to extract the CSS | |
@yak/eslint-plugin | ESLint and Oxlint rules for yak | |
@yak/storybook | Storybook addon for the Vite and webpack builders |
.yak files and other modulesInstall the package and wrap your Next.js config. It works with webpack and Turbopack, no further configuration needed.
npm install @yak/react
// next.config.ts
import { withYak } from "@yak/react/withYak";
const nextConfig = {
// your Next.js config
};
export default withYak(nextConfig);
Then start styling:
import { styled } from "@yak/react";
const StyledDiv = styled.div`
color: #333;
padding: 16px;
background-color: #f0f0f0;
`;
export default function HomePage() {
return <StyledDiv>Hello, yak!</StyledDiv>;
}
Try it in the playground.
Any Vite-based framework works with Vite 7+, including Vite 8 with Rolldown: plain Vite, react-router, TanStack Start and more. Add viteYak() before the React plugin.
// vite.config.ts
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import { viteYak } from "@yak/react/vite";
export default defineConfig({
plugins: [viteYak(), react()],
});
See the Vite guide.
Rsbuild 2+ works through pluginYak, next to pluginReact() and Rsbuild's built-in SWC.
// rsbuild.config.ts
import { defineConfig } from "@rsbuild/core";
im
A folded styled(Component) passes $ props to a non-yak component
https://github.com/galaxuslabs/yak/issues/850
Labels: None
A runtime value in a selector builds without an error and produces broken CSS
https://github.com/galaxuslabs/yak/issues/849
Labels: None
A css block picked from an object builds without an error and gets no styles
https://github.com/galaxuslabs/yak/issues/848
Labels: None
Folding renders the wrong component when a local has the same name
https://github.com/galaxuslabs/yak/issues/835
Labels: None
A folded css prop passes an empty className to a component
https://github.com/galaxuslabs/yak/issues/834
Labels: None
No CONTRIBUTING document was found. Please check the README and open issues.