-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Console error createClient
undefined in client using nuxt
#2225
Comments
+1 for this issue. I can't get this package to work with Nuxt 3 SSR mode. In server side it works. But in browser side, the above code doesn't work. In browser side is the I just want to call the |
+1 getting the same error in svelte kit. I'm assuming something to do with Vite. |
@jackwfrench @albertpratomo @larsdouweschuitema Vite is now supported! Check out v11! Please give feedback if it works for you, and when not, please open a ticket and describe your setup + share the error message. I happily help. V11 is supposed to run everywhere! |
I have tested it on a clean environment and it version
Using
Trying out |
Please check: https://github.com/contentful/contentful.js/?tab=readme-ov-file#installation It is |
We we're trying to use Using the import statement you provided, we also ran into an issue using
|
@larsdouweschuitema I checked our test repository, as we did test with nuxt as well! Its based on the Our versions:
Our
For me, thats the same as you tried. Same version number as well. So, lets try: When you import like this: Thanks! |
Ohh and @larsdouweschuitema, this error:
This is from your bundler. I dont know if you use Nuxt with webpack or vite. In case of webpack, you need to adjust your webpack config as mentioned here: #2318 (comment) |
Hi thanks for getting back to us. Here is the output of the Output:
|
We use the default which is |
Expected Behavior
No console error. Ideally, no workaround required to use
contentful
withnuxt
.Actual Behavior
The app renders. The entry data is retrieved and rendered, but the browser (client) is throwing the bottom console error.
Context
We created a
useContentful
composable which is responsible for connecting to the Contentful space, and exposing a method to fetch the entry. Since we wanted to use this composable in multiple nuxt apps, we wanted to move this composable to a nuxt layer. Once we moved this composable, the workaround for the existingcreateClient
issue no longer works. This means that we cannot use this shared composable for now and all have to do our custom implementation.Using the layer in a "playground" inside of the app, which basically mimics the implementation of using the layer inside of another package, will not throw any error. While using the layer inside of a nuxt app will throw the error no matter what.
I have tried to use various methods to workaround this issue, but none have succeeded.
Environment
The text was updated successfully, but these errors were encountered: