Does iTwinUI work with Qwik apps? #934
-
I was trying to add iTwinUI react components in a demo Qwik app. They say that we can include React UI libraries in Qwik apps using the However, when following the above guide, I was not able to add iTwinUI React components to the project. I constantly keep getting different errors. One of them is: After getting this error, I thought to import directly from - import { IconButton } from "@itwin/itwinui-react";
+ import { IconButton } from "@itwin/itwinui-react/cjs"; I then keep getting this almost identical error: I tried changing with node versions 16 and 18 but faced the same. I also tried changing the import paths to something more specific: import { IconButton } from "@itwin/itwinui-react/cjs/core/Buttons/IconButton"; But that didn't work too. When trying Not sure if they are related, but I also received a syntax error when trying to use Here is a sample repo I created where I tried using Is there something I am missing? Or maybe is there a reason why iTwinUI components won't work in Qwik apps? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
This error likely has nothing to do with qwik itself. I cannot access your sample repo (might be private) but if I had to guess, you are using qwik city, which is an SSR framework for qwik (similar to nextjs or astro). qwik city uses vite for SSR, and it's tricky to make it work out of the box. Try adding After that, try adding export default defineConfig({
/* ...rest of your vite config */
ssr: {
noExternal: [
'@itwin/itwinui-react',
'@itwin/itwinui-css',
]
}
}); |
Beta Was this translation helpful? Give feedback.
This error likely has nothing to do with qwik itself.
I cannot access your sample repo (might be private) but if I had to guess, you are using qwik city, which is an SSR framework for qwik (similar to nextjs or astro). qwik city uses vite for SSR, and it's tricky to make it work out of the box.
Try adding
type: module
to your package.json and see if it changes the error you get.After that, try adding
@itwin/itwinui-react
and@itwin/itwinui-css
tossr.noExternal
in your vite config.