ostrio:flow-router-extra

v3.11.0-rc300.1Published 7 months ago

support support

FlowRouter Extra

Carefully extended flow-router package. FlowRouter is a very simple router for Meteor.js. It does routing for client-side apps and compatible with React, Vue, Svelte, and Blaze.

It exposes a great API for changing the URL and getting data from the URL. However, inside the router, it's not reactive. Most importantly, FlowRouter is designed with performance in mind and it focuses on what it does best: routing.

Features:

Install

meteor add ostrio:flow-router-extra

ES6 Import

1import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
2// Full list of available classes and instances:
3// { FlowRouter, Router, Route, Group, Triggers, BlazeRenderer, RouterHelpers }

Usage

1import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
2
3// DISABLE QUERY STRING COMPATIBILITY
4// WITH OLDER FlowRouter AND Meteor RELEASES
5FlowRouter.decodeQueryParamsOnce = true;
6
7FlowRouter.route('/', {
8  name: 'index',
9  action() {
10    // Render a template using Blaze
11    this.render('templateName');
12
13    // Can be used with BlazeLayout,
14    // and ReactLayout for React-based apps
15  }
16});
17
18// Create 404 route (catch-all)
19FlowRouter.route('*', {
20  action() {
21    // Show 404 error page using Blaze
22    this.render('notFound');
23
24    // Can be used with BlazeLayout,
25    // and ReactLayout for React-based apps
26  }
27});

NOTE: If you're using TypeScript, FlowRouter supports it. For types to work you need to install and follow the instructions of zodern:meteor-types if you haven't done it already.

Documentation

Running Tests

  1. Clone this package
  2. In Terminal (Console) go to directory where package is cloned
  3. Then run:

Meteor/Tinytest

# Default
meteor test-packages ./

# With custom port
meteor test-packages ./ --port 8888

# With local MongoDB and custom port
MONGO_URL="mongodb://127.0.0.1:27017/flow-router-tests" meteor test-packages ./ --port 8888

Running Typescript Test

  1. Install tsd as a global package;
  2. Run tsd in your terminal. tsd will find the correct *.test.d.ts file and return with any errors.

Support this project: