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

SSR Window

Better handling for window and documentt 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 (3 years ago)
  • 4.0.2                                ...           latest (3 years ago)
  • 3.0.0-alpha.4                                ...           next (5 years ago)

21 Versions

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

© 2010 - cnpmjs.org x YWFE | Home | YWFE