3.2024.0-02d8ec9 • Published 3 hours ago

@vue-vapor/server-renderer v3.2024.0-02d8ec9

Weekly downloads
-
License
MIT
Repository
github
Last release
3 hours ago

@vue/server-renderer

Note: as of 3.2.13+, this package is included as a dependency of the main vue package and can be accessed as vue/server-renderer. This means you no longer need to explicitly install this package and ensure its version match that of vue's. Just use the vue/server-renderer deep import instead.

Basic API

renderToString

Signature

function renderToString(
  input: App | VNode,
  context?: SSRContext
): Promise<string>

Usage

const { createSSRApp } = require('vue')
const { renderToString } = require('@vue/server-renderer')

const app = createSSRApp({
  data: () => ({ msg: 'hello' }),
  template: `<div>{{ msg }}</div>`
})

;(async () => {
  const html = await renderToString(app)
  console.log(html)
})()

Handling Teleports

If the rendered app contains teleports, the teleported content will not be part of the rendered string. Instead, they are exposed under the teleports property of the ssr context object:

const ctx = {}
const html = await renderToString(app, ctx)

console.log(ctx.teleports) // { '#teleported': 'teleported content' }

Streaming API

renderToNodeStream

Renders input as a Node.js Readable stream.

Signature

function renderToNodeStream(input: App | VNode, context?: SSRContext): Readable

Usage

// inside a Node.js http handler
renderToNodeStream(app).pipe(res)

Note: This method is not supported in the ESM build of @vue/server-renderer, which is decoupled from Node.js environments. Use pipeToNodeWritable instead.

pipeToNodeWritable

Render and pipe to an existing Node.js Writable stream instance.

Signature

function pipeToNodeWritable(
  input: App | VNode,
  context: SSRContext = {},
  writable: Writable
): void

Usage

// inside a Node.js http handler
pipeToNodeWritable(app, {}, res)

renderToWebStream

Renders input as a Web ReadableStream.

Signature

function renderToWebStream(
  input: App | VNode,
  context?: SSRContext
): ReadableStream

Usage

// inside an environment with ReadableStream support
return new Response(renderToWebStream(app))

Note: in environments that do not expose ReadableStream constructor in the global scope, pipeToWebWritable should be used instead.

pipeToWebWritable

Render and pipe to an existing Web WritableStream instance.

Signature

function pipeToWebWritable(
  input: App | VNode,
  context: SSRContext = {},
  writable: WritableStream
): void

Usage

This is typically used in combination with TransformStream:

// TransformStream is available in environments such as CloudFlare workers.
// in Node.js, TransformStream needs to be explicitly imported from 'stream/web'
const { readable, writable } = new TransformStream()
pipeToWebWritable(app, {}, writable)

return new Response(readable)

renderToSimpleStream

Renders input in streaming mode using a simple readable interface.

Signature

function renderToSimpleStream(
  input: App | VNode,
  context: SSRContext,
  options: SimpleReadable
): SimpleReadable

interface SimpleReadable {
  push(content: string | null): void
  destroy(err: any): void
}

Usage

let res = ''

renderToSimpleStream(
  app,
  {},
  {
    push(chunk) {
      if (chunk === null) {
        // done
        console(`render complete: ${res}`)
      } else {
        res += chunk
      }
    },
    destroy(err) {
      // error encountered
    }
  }
)
3.2024.0-02d8ec9

3 hours ago

3.2024.0-4f90523

11 hours ago

3.2024.0-84cac2d

16 hours ago

3.2024.0-f87abf9

19 hours ago

3.2024.0-77e6755

16 hours ago

3.2024.0-72589be

18 hours ago

3.2024.0-c780263

15 hours ago

3.2024.0-e2b51d6

11 hours ago

3.2024.0-dc574cc

11 hours ago

3.2024.0-bc1b230

16 hours ago

3.2024.0-9346f88

18 hours ago

3.2024.0-b3cb392

19 hours ago

3.2024.0-75314f2

19 hours ago

3.2024.0-76595de

20 hours ago

3.2024.0-e1478e2

11 days ago

3.2024.0-2b0def3

11 days ago

3.2024.0-52c4cf0

11 days ago

3.2024.0-fd25071

11 days ago

3.2024.0-c4f6d0f

11 days ago

3.2024.0-25ff0df

12 days ago

3.2024.0-bfb5250

12 days ago

3.2024.0-8dea04b

12 days ago

3.2024.0-1168fd2

13 days ago

3.2024.0-4cfd4ce

12 days ago

3.2024.0-6f7d219

13 days ago

3.2024.0-273336c

12 days ago

3.2024.0-94ab8ce

13 days ago

3.2024.0-6958051

12 days ago

3.2024.0-098b6fc

13 days ago

3.2024.0-f4cc399

13 days ago

3.2024.0-fb58e65

14 days ago

3.2024.0-70ee69c

14 days ago

3.2024.0-e4df821

14 days ago

3.2024.0-d3a1df2

15 days ago

3.2024.0-a5d6457

15 days ago

3.2024.0-5c86b2a

15 days ago

3.2024.0-e42fecb

15 days ago

3.2024.0-05f4ade

15 days ago

3.2024.0-31e2c91

15 days ago

3.2024.0-caf6aeb

15 days ago

3.2024.0-7feda2e

15 days ago

3.2024.0-2d68429

15 days ago

3.2024.0-43fd261

15 days ago

3.2024.0-fedc46f

15 days ago

3.2024.0-aa5d87b

15 days ago

3.2024.0-d4f878e

15 days ago

3.2024.0-ce6aa06

15 days ago

3.2024.0-ae4ec30

15 days ago

3.2024.0-464b498

17 days ago

3.2024.0-31a9614

16 days ago

3.2024.0-cd58294

17 days ago

3.2024.0-521f3c7

16 days ago

3.2024.0-874dd8a

16 days ago

3.2024.0-4141c16

16 days ago

3.2024.0-dcaad1d

17 days ago

3.2024.0-7fe4712

18 days ago

3.2024.0-3ca2f21

19 days ago

3.2024.0-b3ad1c9

19 days ago

3.2024.0-b7b652e

18 days ago

3.2024.0-4baeb26

19 days ago

3.2024.0-63a2cd8

20 days ago

3.2024.0-2072ae2

21 days ago

3.2024.0-d6c5bcf

22 days ago

3.2024.0-e67e643

23 days ago

3.2024.0-7cad1d6

22 days ago

3.2024.0-d490bf2

23 days ago

3.2024.0-4352137

23 days ago

3.2024.0-4b5bd5b

23 days ago

3.2024.0-a2d0d4d

23 days ago

3.2024.0-f183394

22 days ago

3.2024.0-d286eed

22 days ago

3.2024.0-0013e82

23 days ago

3.2024.0-b9b3e02

24 days ago

3.2024.0-37df043

24 days ago

3.2024.0-1f28ae1

24 days ago

3.2024.0-2fa93ac

23 days ago

3.2024.0-c5fdd37

23 days ago

3.2024.0-1af1f40

25 days ago

3.2024.0-7548865

25 days ago

3.2024.0-af1581b

25 days ago

3.2024.0-66fc3b2

25 days ago

3.2024.0-a68445b

26 days ago

3.2024.0-761f785

25 days ago

3.2024.0-5a599d6

27 days ago

3.2024.0-b447ace

27 days ago

3.2024.0-e640ec6

27 days ago

3.2024.0-b6bde54

28 days ago

3.2024.0-9e0cd20

28 days ago

3.2024.0-a49b6f9

28 days ago

3.2024.0-bdc4322

29 days ago

3.2024.0-22c0538

29 days ago

3.2024.0-a0bd0e9

1 month ago

3.2024.0-38c9d9f

1 month ago

3.2024.0-b961c43

1 month ago

3.2024.0-17e46d4

1 month ago

3.2024.0-f75e834

1 month ago

3.2024.0-e760d68

1 month ago

3.2024.0-98bae0c

1 month ago

3.2024.0-9a33d79

1 month ago

3.2024.0-6c99c7a

1 month ago

3.2024.0-3aba5c9

1 month ago

3.2024.0-dccd6e3

1 month ago

3.2024.0-2e39f3e

1 month ago

3.2024.0-dd6a69b

1 month ago

3.2024.0-157de30

1 month ago

3.2024.0-bb8da6d

1 month ago

3.2024.0-92a4d56

1 month ago

3.2024.0-d6b652a

1 month ago

3.2024.0-db140a1

1 month ago

3.2024.0-339fced

1 month ago

3.2024.0-acc8324

1 month ago

3.2024.0-9f8bf4f

1 month ago

3.2024.0-486f2a8

2 months ago

3.2024.0-5a28a15

2 months ago

3.2024.0-9afaf0d

2 months ago

3.2024.0-100e3fd

2 months ago

3.2024.0-77d74f0

2 months ago

3.2024.0-ba17fb9

2 months ago

3.2024.0-cd8d756

2 months ago

3.2024.0-af516d0

2 months ago

3.2024.0-fe35414

2 months ago

3.2024.0-5b76208

2 months ago

3.2024.0-3992ba5

2 months ago

3.2024.0-08cc2bc

2 months ago

3.2024.0-f1f8b42

2 months ago

3.2024.0-38af9aa

2 months ago

3.2024.0-c633534

2 months ago

3.2024.0-35feb3c

2 months ago

3.2024.0-4d3a8e8

2 months ago

3.2024.0-05774e5

2 months ago

3.2024.0-cf18747

2 months ago

3.2024.0-ed6b171

2 months ago

3.2024.0-9a2c12e

2 months ago

3.2024.0-9dfc966

2 months ago

3.2024.0-5c9a151

2 months ago

3.2024.0-bd888b9

2 months ago

3.2024.0-339e674

2 months ago

3.2024.0-463ae38

2 months ago

3.2024.0-d8b6bcb

2 months ago

3.2024.0-c41eed2

2 months ago

3.2024.0-f3df266

2 months ago

3.2024.0-0169ec4

2 months ago

3.2024.0-ebde516

2 months ago

3.2024.0-31e19df

2 months ago

3.2024.0-b689fa6

2 months ago

3.2024.0-064e6d4

2 months ago

3.2024.0-6a7957d

2 months ago

3.2024.0-d12c2ac

2 months ago

3.2024.0-2de2c1d

2 months ago

3.2024.0-268a2c4

2 months ago

3.2024.0-64e8368

2 months ago

3.2024.0-34ca9f5

2 months ago

3.2024.0-38e167c

2 months ago

3.2024.0-6fc5cfb

2 months ago

3.2024.0-eb3d1fc

2 months ago

3.2024.0-5609644

2 months ago

3.2024.0-2661cb2

2 months ago

3.2024.0-9d03e6e

2 months ago

3.2024.0-12df345

2 months ago

3.2024.0-71c9d27

2 months ago

3.2024.0-fb8609d

2 months ago

3.2024.0-0159af9

2 months ago

3.2024.0-1e00d6c

2 months ago

3.2024.0-808d17d

2 months ago

3.2024.0-4676188

2 months ago

3.2024.0-5d15314

2 months ago

3.2024.0-2b3962f

2 months ago

3.2024.0-2ec05d8

2 months ago

3.2024.0-d282af9

2 months ago

3.2024.0-3e0d646

2 months ago

3.2024.0-fd2d9ff

2 months ago

3.2024.0-e967ed1

2 months ago

3.2024.0-7e0f15f

2 months ago

3.2024.0-83e4102

2 months ago

3.2024.0-6461c0f

2 months ago

3.2024.0-827fced

2 months ago

3.2024.0-463b47e

2 months ago

3.2024.0-b4da5a8

2 months ago

3.2024.0-b4aa5f9

2 months ago

3.2024.0-9412c20

2 months ago

3.2024.0-c79629f

2 months ago

3.2024.0-421eba3

2 months ago

3.2024.0-246badc

2 months ago

3.2024.0-280b8cb

2 months ago

3.2024.0-ebd3710

2 months ago

3.2024.0-b71cc27

2 months ago

3.2024.0-ccfecc9

2 months ago

3.2024.0-03d1d0a

2 months ago

3.2024.0-d20cf6d

2 months ago

3.2024.0-11b99ba

2 months ago

3.2024.0-d8880c8

2 months ago

3.2024.0-61ada62

2 months ago

3.2024.0-f4768bc

2 months ago

3.2024.0-d3ca3f7

2 months ago

3.2024.0-91997bb

2 months ago

3.2024.0-26ad63b

2 months ago

3.2024.0-b925c62

2 months ago

3.2024.0-ffb79a0

2 months ago

3.2024.0-ccd3f39

2 months ago

3.2024.0-5a0365d

2 months ago

3.2024.0-7f86144

2 months ago

3.2024.0-5a0bc11

2 months ago

3.2024.0-320e8f7

2 months ago

3.2024.0-76fbceb

2 months ago

3.2024.0-9cc0a2b

2 months ago

3.2024.0-4af8e87

2 months ago

3.2024.0-04fe609

2 months ago

3.2024.0-83641f7

3 months ago

3.2024.0-0e57653

3 months ago

3.2024.0-cb53a1e

3 months ago

3.2024.0-fac30af

3 months ago

3.2024.0-2c15171

3 months ago

3.2024.0-65909f6

3 months ago

3.2024.0-2075042

3 months ago

3.2024.0-d7bd6c9

3 months ago

3.2024.0-d9907ef

3 months ago

3.2024.0-ff943f4

3 months ago

3.2024.0-7072932

3 months ago

3.2024.0-0e0ee5b

3 months ago

3.2024.0-fb3e8ee

3 months ago

3.2024.0-d58497f

3 months ago

3.2024.0-4c9d891

3 months ago

3.2024.0-a87d212

3 months ago

3.2024.0-26f29b2

3 months ago

3.2024.0-e5c1f8d

3 months ago

3.2024.0-ddaf23e

3 months ago

3.2024.0-004edd3

3 months ago

3.2024.0-c1d9b64

3 months ago

3.2024.0-e91dde5

3 months ago

3.2024.0-c9db3fa

3 months ago

3.2024.0-669fec8

3 months ago

3.2024.0-5819dc9

3 months ago

3.2024.0-7aae631

3 months ago

3.2024.0-23653cc

3 months ago

3.2024.0-36b6e7e

3 months ago

3.2024.0-fa0ca8a

3 months ago

3.2024.0-531f4f0

3 months ago

3.2024.0-ba29b4c

3 months ago

3.2024.0-6ced902

3 months ago

3.2024.0-b11ecbd

3 months ago

3.2024.0-1710bfd

3 months ago

3.2024.0-3a6a1dd

3 months ago

3.2024.0-ea5c361

3 months ago

3.2024.0-6c25fb6

3 months ago

3.2024.0-7fd7742

3 months ago

3.2024.0-e10f7d1

3 months ago

3.2024.0-95b08e8

3 months ago

3.2024.0-66cea4b

3 months ago

3.2024.0-3d10925

3 months ago

3.2024.0-bf5f7c3

3 months ago

3.2024.0-f7080ef

3 months ago

3.2024.0-afa7ee2

3 months ago

3.20240210.0

3 months ago

3.2024.0-3550765

3 months ago

3.20240210.1

3 months ago

3.0.0-35f69d1

3 months ago

3.2024.1

3 months ago

3.2024.0

3 months ago

3.2024.0-9e029e8

3 months ago

3.2024.0-2486d99

3 months ago

3.2024.0-184d72e

3 months ago

3.2024.0-8bd92c9

3 months ago

3.2024.0-b5e12ea

3 months ago

3.20240209.0

3 months ago

0.20240209.3

3 months ago

0.20240209.2

3 months ago

0.20240209.1

3 months ago

0.20240209.0

3 months ago