JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 53728
  • Score
    100M100P100Q155659F
  • License MIT

Package Exports

  • @css-render/vue3-ssr
  • @css-render/vue3-ssr/esm/index.js
  • @css-render/vue3-ssr/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@css-render/vue3-ssr) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@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");
  },
});