1. @css-render/vue3-ssr
## Example
@css-render/vue3-ssr
Package: @css-render/vue3-ssr
Last modified: Sun, 05 May 2024 06:36:04 GMT
Version: 0.15.14
License: MIT
Downloads: 91,945

Install

npm install @css-render/vue3-ssr
yarn add @css-render/vue3-ssr

@css-render/vue3-ssr

Example

Server

 import { createSSRApp } from 'vue'
import { renderToString } from '@vue/server-renderer'
import { setup } = from '@css-render/vue3-ssr'

// For each request, you need to create a new app
const ssrApp = createSSRApp(App)
const { collect } = setup(ssrApp)

renderToString(ssrApp).then(appHtml => {
  const css = collect()
  const page = `<!DOCTYPE html>
  <html>
    <head>${css}</head>
    <body><div id="app">${appHtml}</div></body>
  </html>`
})

Component

 import { defineComponent } from 'vue'
import { useSsrAdapter } from '@css-render/vue3-ssr'

const Child = defineComponent({
  setup() {
    c("div", {
      color: "red",
    }).mount({
      id: "mount-id",
      // It always returns undefined in browser (document === undefined)
      ssr: useSsrAdapter(),
    });
  },
  render() {
    return h("div", null, "Child");
  },
});

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin