Skip to content

Nextjs Turbopack: assert is not defined #224

@anielfeyt

Description

@anielfeyt

I'm currently using Nextjs 15.2.2 with MUI 6.4.7 and tss-react 4.9.15. I am getting the error assert is not defined when calling useStyles() in a component which is marked "use client". I am using Nextjs app router. Am I missing something?

Root layout:

import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import { AppRouterCacheProvider } from "@mui/material-nextjs/v15-appRouter";
import { ThemeProvider } from "@mui/material/styles";
import theme from "../theme";
import "./globals.css";

const geistSans = Geist({
  variable: "--font-geist-sans",
  subsets: ["latin"],
});

const geistMono = Geist_Mono({
  variable: "--font-geist-mono",
  subsets: ["latin"],
});

export const metadata: Metadata = {
  title: "Create Next App",
  description: "Generated by create next app",
};

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html lang="en">
      <body className={`${geistSans.variable} ${geistMono.variable}`}>
        <AppRouterCacheProvider options={{ enableCssLayer: true }}>
          <ThemeProvider theme={theme}>{children}</ThemeProvider>
        </AppRouterCacheProvider>
      </body>
    </html>
  );
}

Button.tsx:

"use client";
import React from "react";
import { tss } from "tss-react/mui";

const useStyles = tss.create({
  root: {
    color: "red",
  },
});

export default function Button() {
  const { classes } = useStyles();
  return <button className={classes.root}>Click me</button>;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions