ssr-window
Better handling for window object in SSR environment
Last updated 4 years ago by nolimits4web .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ssr-window 
SYNC missed versions from official npm registry.

SSR Window

Better handling for window and document object in SSR environment.

This library doesn't implement the DOM (like JSDOM), it just patches (or creates window and document objects) to avoid them to fail (throw errors) during server-side rendering.

Was created for use in:

Installation

Library available on NPM:

npm i ssr-window

Usage

import { window, document } from 'ssr-window';

window.addEventListener('resize', () => {});

const div = document.querySelectorAll('div');

Extending

If you rely on some window/document properties which are not included here, you can use extend helper to add them:

import { window, document, extend } from 'ssr-window';

// add window.navigator.language
extend(window, {
  navigator: {
    language: 'en',
  },
});

// add document.body
extend(document, {
  body: {
    /* ... */
  },
});

Contribution

Yes please! See the contributing guidelines for details.

Licence

This project is licensed under the terms of the MIT license.

Current Tags

  • 4.0.0-beta.3                                ...           beta (5 years ago)
  • 4.0.2                                ...           latest (4 years ago)
  • 3.0.0-alpha.4                                ...           next (6 years ago)

21 Versions

  • 4.0.2                                ...           4 years ago
  • 4.0.1                                ...           4 years ago
  • 4.0.0                                ...           5 years ago
  • 4.0.0-beta.3                                ...           5 years ago
  • 4.0.0-beta.2                                ...           5 years ago
  • 4.0.0-beta.1                                ...           5 years ago
  • 3.0.0                                ...           5 years ago
  • 3.0.0-alpha.4                                ...           6 years ago
  • 3.0.0-alpha.3                                ...           6 years ago
  • 2.0.0                                ...           6 years ago
  • 2.0.0-beta.8                                ...           6 years ago
  • 3.0.0-alpha.2                                ...           6 years ago
  • 3.0.0-alpha.1                                ...           6 years ago
  • 2.0.0-beta.7                                ...           6 years ago
  • 2.0.0-beta.6                                ...           6 years ago
  • 2.0.0-beta.5                                ...           6 years ago
  • 2.0.0-beta.4                                ...           6 years ago
  • 2.0.0-beta.3                                ...           6 years ago
  • 2.0.0-beta.2                                ...           6 years ago
  • 1.0.1                                ...           8 years ago
  • 1.0.0                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 20
This Month 39
Last Day 2
Last Week 40
Last Month 195
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (2)

Copyright 2013 - present © cnpmjs.org | Home |