New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

spaghetti-router

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spaghetti-router

Cook your React pages with spaghetti-router today!

  • 0.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

spaghetti-router

A simple user-friendly router library for your React application. It is written in TypeScript, but you can also use it in JavaScript projects.

Installation

Install using npm:

npm install spaghetti-router

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

// TypeScript
import React from "react";
import ReactDOM from "react-dom";
import { Router } from "spaghetti-router";

ReactDOM.render(<Router />, document.getElementById("root"));

// JavaScript
const React = require("react");
const SpaghettiRouter = require("spaghetti-router");

React.render(<SpaghettiRouter.Router />, document.getElementById("root"));

Usage

The basic working router looks like this:

// TypeScript
import React from "react";
import ReactDOM from "react-dom";
import { Router, IRoute } from "spaghetti-router";

const routePaths: Array<IRoute> = [
  {
    path: "/",
    component: HomeView,
  },
  {
    path: "/about",
    component: AboutView,
  },
  {
    path: "/user/:id", //work in progress
    component: UserView,
  },
];

class HomeView extends React.Component {
  render(): ReactNode {
    return <button onClick={() => Router.openView(<AboutView />)}>About</button>;
  }
}

ReactDOM.render(<Router routes={routePaths} />, document.getElementById("root"));

Navigation

MethodDescription
Router.closeView()Close the active view
Router.openComponent()Open a new React component
Router.openUrl()Open a new component with url
Router.openView()Open a new JSX Element (type safety props)

Keywords

FAQs

Package last updated on 29 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc