Skip to content

Does remix-flat-routes also work for Remix run version 1.x (e.g.: 1.9.x)? #95

Answered by kiliman
mtin79 asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, remix-flat-routes works with all versions of Remix from v1.5+.

The simplest way to configure it is to just copy the configuration from the README.

Just make sure to set the ignoredRouteFiles to ignore ALL files, so Remix doesn't try to process them before remix-flat-routes.

const { flatRoutes } = require('remix-flat-routes')

/**
 * @type {import("@remix-run/dev").AppConfig}
 */
module.exports = {
  // ignore all files in routes folder to prevent
  // default remix convention from picking up routes
  ignoredRouteFiles: ['**/*'],
  routes: async defineRoutes => {
    return flatRoutes('routes', defineRoutes)
  },
}

If you're using ESM, then just convert the syntax to:

import { flatRoutes

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@mtin79
Comment options

@dev-1tm-solutions
Comment options

@kiliman
Comment options

Answer selected by mtin79
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants