npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@sylphx/silk-nextjs

v3.3.5

Published

Next.js integration for Silk - zero-runtime CSS-in-TypeScript with App Router support

Readme

@sylphx/silk-nextjs

Next.js integration for Silk - zero-runtime CSS-in-TypeScript with App Router support.

Installation

npm install @sylphx/silk @sylphx/silk-nextjs @sylphx/babel-plugin-silk

Quick Start

1. Configure Next.js

// next.config.mjs
import { withSilk } from '@sylphx/silk-nextjs';

export default withSilk({
  // Your Next.js config
});

2. Add Babel Configuration

Create a .babelrc file in your project root:

{
  "presets": ["next/babel"],
  "plugins": ["@sylphx/babel-plugin-silk"]
}

That's it! Silk supports both Webpack and Turbopack modes:

  • Webpack Mode (Recommended): Zero codegen - automatic CSS extraction via virtual module
  • Turbopack Mode: CLI codegen required - generate CSS files manually

3. Use Silk in your components

// app/page.tsx
import { css } from '@sylphx/silk';

const styles = {
  container: css({
    display: 'flex',
    padding: '2rem',
    background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)'
  }),
  title: css({
    fontSize: '2rem',
    fontWeight: 'bold',
    color: 'white'
  })
};

export default function Home() {
  return (
    <div className={styles.container}>
      <h1 className={styles.title}>Hello Silk!</h1>
    </div>
  );
}

Configuration

Root-level app/ Directory

If your project uses a root-level app/ directory (not src/app/), configure srcDir:

// next.config.mjs
export default withSilk({}, {
  srcDir: './app',  // Scan root-level app/ directory
  debug: true       // Optional: enable debug logging
});

Custom Source Directory

export default withSilk({}, {
  srcDir: './src',           // Default: './src'
  virtualModuleId: 'silk.css', // Default: 'silk.css'
  minify: true,               // Minify CSS (default: production only)
  debug: false                // Debug logging
});

Supported Directory Structures

Root-level app/ directory:

my-app/
├── app/
│   ├── layout.tsx
│   └── page.tsx
└── next.config.mjs  ← srcDir: './app'

src/app/ directory (default):

my-app/
├── src/
│   └── app/
│       ├── layout.tsx
│       └── page.tsx
└── next.config.mjs  ← srcDir: './src' (or omit)

Turbopack Support (Next.js 16+)

Silk supports both Webpack and Turbopack modes, but they work differently:

Webpack Mode (Recommended - Zero Codegen)

next dev     # Webpack mode (automatic CSS extraction)
next build   # Production build

Features:

  • ✅ Zero codegen required
  • ✅ Automatic CSS extraction via SilkWebpackPlugin
  • ✅ Virtual CSS module (silk.css)
  • ✅ Zero runtime overhead

Turbopack Mode (Requires CLI)

# Install CLI tool
npm install @sylphx/silk-cli

# Add package.json scripts
{
  "predev": "silk generate --src ./app --output ./silk.generated.css",
  "prebuild": "silk generate --src ./app --output ./silk.generated.css",
  "dev": "next dev --turbo",
  "build": "next build"
}

# Import generated CSS
// app/layout.tsx
import '../silk.generated.css'

Features:

  • ✅ 10x faster builds
  • ✅ Babel plugin transforms css() calls
  • ❌ Requires CLI codegen
  • ❌ Physical CSS files

Turbopack vs Webpack

| Feature | Webpack | Turbopack | |---------|---------|-----------| | Build Speed | Standard | 10x faster | | Codegen | ❌ None | ✅ Required | | CSS Output | Virtual module | Physical file | | Setup | Simple | CLI + Scripts |

Recommendation: Use Webpack for zero-codegen development. Use Turbopack if you need faster builds and don't mind the CLI step.

Compatibility

  • Next.js: 13.x, 14.x, 15.x, 16.x
  • React: 18.x, 19.x
  • Build Tools:
    • Turbopack: ✅ Recommended (10x faster)
    • Webpack: ✅ Supported (zero-codegen)