Custom type components won't render in static nuxt build
See original GitHub issueVersion
module: 0.9.1 nuxt: ^2.15.3
Nuxt configuration
mode:
- universal
- spa
Nuxt configuration
Static generation
Reproduction
Custom components for custom types will work in dev mode, but will not generate for static.
What is expected?
Custom block types should be created in static site generation, just like dev mode
What is actually happening?
Errors from any kind of asyncData or fetch happening on server to build site throwing up:
WARN Cannot stringify a function String
WARN Cannot stringify a function Object
WARN Cannot stringify a function render
WARN Cannot stringify a function hook
WARN Cannot stringify a function VueComponent
Steps to reproduce
- Add @nuxtjs/sanity to a fresh Nuxt boilerplate
- Fetch sanity content that contains a custom type
- Confirm it works in dev mode
- Run
nuxt generate && nuxt start
- You should see similar above errors and the custom components aren’t rendered in pages
Additional information
Checklist
- I have tested with the latest Nuxt version and the issue still occurs
- I have tested with the latest module version and the issue still occurs
- I have searched the issue tracker and this issue hasn’t been reported yet
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
Custom type components won't render in static nuxt build #123
I found I had two problems, when trying the nuxt module it was fetch vs asyncData , and when trying the @rdunk sanity-blocks-vue-component...
Read more >Static directory - Nuxt
The static directory is directly mapped to the server root () and contains files that likely won't be changed. All included files will...
Read more >Nuxt not rendering html for components - vue.js - Stack Overflow
I'm building an online shop using nuxt and nuxt generate for ... but I guess it should render the components since it's a...
Read more >Creating Server-side Rendered Vue.js Apps Using Nuxt.js
When initially loading your website, your browser doesn't receive a complete page to display. Instead, it gets a bunch of pieces and instructions...
Read more >Web Components in Server-Side Rendered (SSR) and Static ...
Below, I'm going to show you how to pre-render custom web components in Next.js. By extracting the logic used to create the template...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @danielroe, thanks for getting back on this. I found I had two problems, when trying the nuxt module it was
fetch
vsasyncData
, and when trying the @rdunksanity-blocks-vue-component
I was mistakenly leaving... mode: client }
for the plugin innuxt.config.js
, which meant SSR didn’t have access to the component on generation. Thanks again for your help.Just looking at your comment again, the key difference is that
fetch
stringifies the entire component state, whereasasyncData
just stringifies whatasyncData
returns. I suspect you have set a data property to a component. Likely you can fix by setting increated()
instead (with an added performance benefit as it won’t be reactive) or via a computed property. For example: