npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

remix-kiss-routes

v0.1.4

Published

Build cleanly structured routes for Remix using folders.

Downloads

3

Readme

Remix Keep It Super Simple (KISS) Routes

[!WARNING] This package is in active development, API changes are no longer expected. We're getting close to 1.0.0, we now have this in production on a few sites.

The goal of this package is to provide a simple way to define routes in Remix using a structured file system. The routing method in Remix is OK, but has many nuances and arbitrary rules that make it difficult to onboard new developers, leaves file/folder names littered with _,[,+ amongst other special characters with little meaning unless you know the rules and odd nuances.

🤷‍♂️ Why?

Frustration with a flat folder routing system, a project with 1000's of routes is not fun to open in VSCode, the sidebar becomes unmanageably long, scrolling up and down becomes tedious very quickly.

We want to be able to define our routes in a way that makes intuitive sense, maps to the web in a logical predictable way, and is easy to keep well organized across teams.

💡 Concepts

  • Routes are defined and nested using folders, very similar to how you'd layout HTML files on an nginx server.
  • _layout files wrap all routes downstream, these need an <Outlet /> to render the child routes.
  • _index files are the default file for a folder, eg: /users/_index.tsx would become /users.
  • Variables are denoted using $ in the file path, eg: /users/$id/edit.tsx would become /users/123/edit
  • You can replace folders with a "virtual" folder using a . in the filename, eg: /users.$id.edit.tsx would become /users/123/edit.
  • You can escape special characters in the file path using [], eg: /make-[$$$]-fast-online.tsx would become /make-$$$-fast-online
  • Files and folders prefixed with an _ become invisible, allowing for folder organization without affecting the route path eg: /_legal-pages/privacy-policy.tsx would become /privacy-policy
  • Files not ending in .jsx, .tsx, .js, .ts are ignored, allowing you to keep assets and other files in the same folder as your routes.

🔮 Example

📂 File System

├── _index.jsx
├── _layout.jsx
├── users
│   ├── _index.jsx
│   ├── _layout.jsx
│   ├── $id
│   │   ├── _index.jsx
│   │   ├── _layout.jsx
│   │   └── edit.jsx
|   └── $id.view.jsx
└── _legal-pages
    └── privacy-policy.jsx

🧬 Routes Generated

/_index.jsx -> /
/users/_index.jsx -> /users
/users/$id/_index.jsx -> /users/$id
/users/$id/edit.jsx -> /users/$id/edit
/users/$id.view.jsx -> /users/$id/view
/_legal-pages/privacy-policy.jsx -> /privacy-policy

✨ See how super simple that is!

🔨 Usage

🚀 Install the package:

npm install -D remix-kiss-routes

💿 Remix Config

// remix.config.js
import { kissRoutes } from 'remix-kiss-routes'
// ---- OR ---- //
const { kissRoutes } = require('remix-kiss-routes')


/** @type {import('@remix-run/dev').AppConfig} */
module.exports = {
    ignoredRouteFiles: ["**/*"],
    routes: defineRoutes => {
        return kissRoutes(defineRoutes)
        // or  kissRoutes(defineRoutes, RemixKissRoutesOptions)
    },
}

Parameters:

const RemixKissRoutesOptions = {
    app: './app', // where your root.jsx file is located
    routes: 'routes', // where your routes are located relative to app
    caseSensitive: false, // whether or not to use case sensitive routes
    variableCharacter: '$', // the character to denote a variable in the route path
    pathlessCharacter: '_', // the character to make a file or folder pathless (invisible)
    delimiterCharacter: '.', // used for virtual folders, internally replaced with '/'
    layoutFileName: '_layout',  // the name of the layout file
    indexFileName: '_index', // the name of the index file
}