Giter Site home page Giter Site logo

history's Introduction

history Travis npm package

history is a JavaScript library that lets you easily manage session history in browsers, testing environments, and (soon, via React Native) native devices. history abstracts away the differences in these different platforms and provides a minimal API that lets you manage the history stack, navigate, confirm navigation, and persist state between sessions. history is library-agnostic and may easily be included in any JavaScript project.

Coveralls Discord

Docs & Help

For questions and support, please visit our channel on Reactiflux or Stack Overflow. The issue tracker is exclusively for bug reports and feature requests.

Installation

Using npm:

$ npm install history

Then with a module bundler like webpack, use as you would anything else:

// using an ES6 transpiler, like babel
import { createHistory } from 'history'

// not using an ES6 transpiler
var createHistory = require('history').createHistory

The UMD build is also available on npmcdn:

<script src="https://npmcdn.com/history/umd/History.min.js"></script>

You can find the library on window.History.

Basic Usage

A "history" encapsulates navigation between different screens in your app, and notifies listeners when the current screen changes.

import { createHistory } from 'history'

let history = createHistory()

// Listen for changes to the current location. The
// listener is called once immediately.
let unlisten = history.listen(location => {
  console.log(location.pathname)
})

history.push({
  pathname: '/the/path',
  search: '?a=query',
  state: { the: 'state' }
})

// When you're finished, stop the listener.
unlisten()

You can find many more examples in the documentation!

Thanks

A big thank-you to Dan Shaw for letting us use the history npm package name! Thanks Dan!

Also, thanks to BrowserStack for providing the infrastructure that allows us to run our build in real browsers.

history's People

Contributors

mjackson avatar taion avatar michalkvasnicak avatar timdorr avatar ryanflorence avatar jeffreywescott avatar agundermann avatar knowbody avatar acdlite avatar jnv avatar pwmckenna avatar jinroh avatar threepointone avatar koba04 avatar iam4x avatar aaronjensen avatar asaf avatar trysound avatar klzns avatar gaearon avatar djkirby avatar eknuth avatar jlongster avatar macroz avatar prayagverma avatar rryan avatar robcolburn avatar jesenko avatar vslinko avatar masonicboom avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.