npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@aklesky/vite-react-ssr-plugin

v0.6.7

Published

Vite Plugin to handle react server side rendering.

Downloads

5

Readme

Vite React Server Side Plugin

A Plugin for Vite to enable Server Side Rendering for React with Pipeable Stream.

Installation

npm

npm install -D @aklesky/vite-react-ssr-plugin

yarn

yarn add -D @aklesky/vite-react-ssr-plugin

Usage

import plugin from '@aklesky/@aklesky/vite-react-ssr-plugin/plugin.js'
import { defineConfig } from 'vite'

export default defineConfig({
    // ...
    root: "src",
    plugins: [plugin({
        entry: './entries/server.tsx',
        bootstrapModules: ['./entries/client.tsx'],
    })],
    // ...
  }
)

Configuration Parameters

entry

An entry point for loading a React component on a server via ssrLoadModule

More about ssrLoadModule

    entry: string

enableDoctypeHeader

Enable or disable the doctype header to be added to the stream.

Enabled by default

    enableDoctypeHeader?: boolean

    // ...
    if (options.enableDoctypeHeader) {
        http.ServerResponse.write('<!DOCTYPE html>')
    }

ignoreUrlExpressions

An array of regular expressions to ignore the certain urls.

By default, this will exclude any URLs with file extensions and URLs starting with "/@...".

uri.pathname = '/@vite/client'

default [/\.([^.]*?)(?=\?|#|$)/, /\/@[.]*?/]

    ignoreUrlExpressions?: RegExp[]

title

An Html Title to be added to the stream.

default: Vite.js React Server Side Plugin

    title?: string

nonce

A nonce string to allow scripts for script-src Content-Security-Policy.

    nonce?: string

identifierPrefix

A string prefix React uses for IDs generated by useId.

    identifierPrefix?: string

progressiveChunkSize

The number of bytes in a chunk.

    progressiveChunkSize?: number

default 12800

namespaceURI

A string with the root namespace URI for the stream. Defaults to regular HTML.

    namespaceURI?: string

Read more about the namespaceURI parameter

bootstrapScripts

An array of string URLs for the <script> tags to emit on the page. Use this to include the <script type="module"> that calls hydrateRoot.

   bootstrapScripts?: string[]

Read more about the bootstrapScripts

bootstrapModules

An array of string URLs for the <script type="module"> tags to emit on the page.

    bootstrapModules?: string[]

Read more about the bootstrapModules

enableTimeout

Enable the server rendering to “give up” after a timeout

default false

    enableTimeout?: boolean

timeout

Force the server rendering to “give up” after a timeout

    timeout?: number

default 10000 ms

addClosingHtmlBodyTag

Write closing body and html tags to the end of the stream and end it.

    addClosingHtmlBodyTag?: boolean

default true

Writable.end('\<\/body>\<\/html\>')

Event Handlers

These event handler functions primarily focus on receiving two arguments and return a callback function that takes in additional arguments.

Learn more about the callback function that takes in additional arguments.

onAllReadyHandler

    onAllReadyHandler?: (req: http.IncomingMessage, res: http.ServerResponse) => (pipe: () => Writable, error?: Error) => Promise<void>

onShellReadyHandler

    onShellReadyHandler?: (req: http.IncomingMessage, res: http.ServerResponse) => (pipe: () => Writable, error?: Error) => Promise<void>

onShellErrorHandler

    onShellErrorHandler?: (req: http.IncomingMessage, res: http.ServerResponse) => (error: unknown, writeable: Writable) => Promise<void>

onErrorHandler

    onErrorHandler?: (req: http.IncomingMessage, res: http.ServerResponse) => (error: unknown, writeable: Writable) => Promise<void>

onFinishEventHandler

    onFinishEventHandler?: (req: http.IncomingMessage, res: http.ServerResponse) => () => Promise<string | void>

onTimeoutHandler

    onTimeoutHandler?: (req: http.IncomingMessage, res: http.ServerResponse) => (cb?: () => void) => Promise<void>