Search code examples
nuxt.jsserver-side-renderingnuxt3.js

Nuxt SSR without client call


Hello i want to know if i can renderize a .vue component into a only server side variable. Usually nuxt renderize html code after a client call. It generate html code on the server side and send it to the client. In my case i need to do the same thing but, the code should be sent into my same server. My idea is to make a direct call to the internal Nuxt renderize function. I would do this call from my server webhook.

so i would do something like that (pseudocode)

//my-server-webhook.ts

const html = await getRenderedComponent('/path/to/component.vue')

i just wonder if nuxt allow to do something like this on a easy way. thank you in advance.


Solution

  • i solved my problem.

    npm i puppeteer
    

    puppeteer is a headless browser that can be used into nodejs servers. Now i can renderize html pages and turn them into images all from my server.