Skip to content
Discussion options

You must be logged in to vote

You can also do it with global variables.

// root.tsx

export const loader = () => {
  return json({
    COMMIT_SHA: process.env. COMMIT_SHA
  })
}

export default function Root() {
  const { COMMIT_SHA } = useLoaderData()

  return (
    <html lang="en">
      <head>
        <meta charSet="utf-8" />
        <meta name="viewport" content="width=device-width,initial-scale=1" />
        <Meta />
        <Links />
        <script dangerouslySetInnerHTML={{ __html: `window.COMMIT_SHA = '${COMMIT_SHA}'` }}>
      </head>
      <body>
        <Outlet />
        <ScrollRestoration />
        <Scripts />
        <LiveReload />
      </body>
    </html>
  )
}

in this way, You can read it in entry.…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@horsejockey
Comment options

@lili21
Comment options

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