@harlem/plugin-ssr

The official server-side rendering plugin for Harlem
14,341 515
Install
npm install @harlem/plugin-ssr
Latest Version:3.1.8
Vue:3
License:MIT
Last Updated:Jun 3, 2024
Links: GitHub  ·  npm
Maintainer: andrewcourtice

Harlem Server-Side Rendering Plugin

The SSR plugin adds support for using Harlem in a Vue server-side rendered application.

Installation

Before installing the ssr plugin make sure you have installed harlem.

yarn add @harlem/plugin-ssr
# or
npm install @harlem/plugin-ssr

Usage

Server

Create an instance of the plugin and register it with Harlem on the server:

import App from './app.vue';

import {
    createVuePlugin
} from 'harlem';

import {
    createServerSSRPlugin
} from '@harlem/plugin-ssr';

createSSRApp(App)
    .use(createVuePlugin({
        plugins: [
            createServerSSRPlugin()
        ]
    }));

Generate the bridging script block and insert it into the server-rendered content:

import {
    renderToString
} from '@vue/server-renderer';

import {
    getBridgingScriptBlock
} from '@harlem/plugin-ssr';

let output = await renderToString(app);
output += getBridgingScriptBlock();

Client

Create an instance of the plugin and register it with Harlem on the client:

import App from './app.vue';

import {
    createVuePlugin
} from 'harlem';

import {
    createClientSSRPlugin
} from '@harlem/plugin-ssr';

createApp(App)
    .use(createVuePlugin({
        plugins: [
            createClientSSRPlugin()
        ]
    }));

Types that are not support by JSON serialisation will not be transferred from server to client. See the MDN documentation on JSON serialisation for more information: MDN docs

Related Packages

@harlem/plugin-devtools

The official Vue devtools plugin for Harlem

11,973 515
@harlem/core

Powerfully simple global state management for Vue 3

39,073 515
harlem

Powerfully simple global state management for Vue 3

4,993 515
vue-ssr-webpack-plugin

webpack plugin for generating a bundle manifest to use with Vue 2.x bundleRender...

100,967
@harlem/utilities

Harlem utilities package

21,025 515

Version History

Version Released License
3.1.8 MIT
3.1.7 MIT
3.1.6 MIT
3.1.5 MIT
3.1.4 MIT
Pre-releases (25)
Version Released License
3.0.0-beta.1 MIT
3.0.0-beta.0 MIT
2.4.0-beta.11 MIT
2.4.0-beta.10 MIT
2.4.0-beta.9 MIT