🚨 Disclaimer: Routify 3 is currently in Release Candidate stage.

Please be aware that while the documentation is comprehensive, it may contain inaccuracies or errors. The codebase is also subject to changes that could affect functionality. We appreciate your understanding and welcome any feedback or contributions.

api

Plugins

Plugins can be created with the following structure

export default options => ({
    name: 'string',
    before: 'string', // optional plugin name this plugin should run before
    after: 'string', // optional plugin name this plugin should run after
    build: ({ instance }) => void
})

Example

// this plugin sorts routes by the index prefixed to their names
// eg. 1.guide.svelte, 2.api.svelte
export default options => ({
    name: 'indexByName',
    
    // we want to run our plugin before we write our routes to disk
    before: 'exporter', 
    
    
    build: ({ instance }) => {

        // iterate over all nodes
        instance.nodeIndex.forEach(node => {

            // if our node name matches 123.foo
            // set the name to foo and the meta index to 123
            const matches = node.name?.match(/^(d+).(.+)/)
            if (matches) {
                const [, index, name] = matches
                node.name = name
                node.meta.index = index
            }
        })
    }
})

Using a plugin

package.json

{
    "routify": {
        "plugins": [
            "indexByName"
        ]
    }
}

package.json with options

{
    "routify": {
        "plugins": [
            {
                "path": "indexByName",
                "options": { }
            }
        ]
    }
}

routify.config.js

import indexByName from './path/to/plugin'

export default {
  plugins: [
      indexByName({/** options*/})
  ]
}



Need a developer? Hire me!