1

I am building a npm package for nextjs projects which works fine so far. However, the package consists of several server components and 1 client component. This means the file has 'use client' on top of the file. When I build my package, and try to load the component inside my nextjs project I get the following error:

Module parse failed: Unexpected token (7:43)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

When I remove the 'use client' statement, the error goes away and the component renders. However I need it to be a client since I want to use some client methods.

My package src are ts and tsx files and it builds to dist in .js and .jsx files, which work for server components, but apparently not for client components. How do I fix this?

Skywalker
  • 11
  • 3

0 Answers0