remix-seo icon indicating copy to clipboard operation
remix-seo copied to clipboard

Consume route manifest from server build instead of context

Open lpsinger opened this issue 9 months ago • 0 comments

Perhaps surprisingly, you can import the server build in any route module, like this:

import * as build from '@remix-run/dev/server-build'
import { useLoaderData } from '@remix-run/react'

export function loader() {
  return Object.keys(build.routes)
}

export default function () {
  const routes = useLoaderData<typeof loader>()
  return (
    <>
      <h1>List of routes</h1>
      <ul>
        {routes.map((route) => (
          <li key={route}>{route}</li>
        ))}
      </ul>
    </>
  )
}

As a result, customizing the Remix server entry point is not necessary.

See https://github.com/remix-run/remix/discussions/2912#discussioncomment-7013261

lpsinger avatar Sep 18 '23 21:09 lpsinger