2.1.1 • Published 9 years ago

slammy-router v2.1.1

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
9 years ago

Slammy-Router

Build Status

Slammy-Router is a tiny React router implementation, usable for single page apps. It only uses hashbangs, no pushState.

Installation

npm install --save-dev slammy-router

Usage example

import React from 'react';
import ReactDOM from 'react-dom';
import Router from 'slammy-router';

class DefaultRoute extends React.Component {
	render() {
		
		return (
			<div>
				<p>Default route</p>
				<a href="#/route/second">Go to second route</a>
			</div>
		);
		
	}
};

class AnotherRoute extends React.Component {
	render() {
		
		return (
			<div>
				<p>Second route</p>
				<a href="#/route/params/ReactUser">Go to parameterized route</a>
			</div>
		);
		
	}
};

class ParamRoute extends React.Component {
	render() {
		
		return (
			<div>
				<p>Route with param "greeting": {this.props.params.greeting}</p>
			</div>
		);
		
	}
};

class NoSuchRoute extends React.Component {
	render() {
		
		return (
			<div>
				<p>The view for '{this.props.route}' was not found</p>
			</div>
		);
		
	}
};

let routes = {
	"/route/first": DefaultRoute,
	"/route/second": AnotherRoute,
	"/route/params/:greeting": ParamRoute
};

ReactDOM.render(<Router default="/route/first" notfound={NoSuchRoute} routes={routes} />, document.getElementById('example'));

Demo

You can clone this repository, and build (npm run build) from the example directory. Point your web browser to the index file of that same directory to try Slammy-Router.

Building this repo

$ npm install && gulp

Building the example

$ cd example/ && npm install && npm run build
2.1.1

9 years ago

2.1.0

10 years ago

2.0.3

10 years ago

2.0.2

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago