SolidJSS
SolidJSโ€ข3y agoโ€ข
13 replies
foxpro ๐Ÿ

`@solidjs/router` doesn't navigate in production mode

export function App() {
   return (
      <MetaProvider>
         <Title>SferaDel</Title>
         <I18n>
            <div>App outline</div>
            <SPARouter />
            <Toaster />
         </I18n>
      </MetaProvider>
   )
}
// spa_router.tsx:
import { LoginPage } from '~/views/login.tsx'
export const AppRoute = Object.freeze({
   Index: '/',
   Login: '/login',
})
export function SPARouter() {
   return (
      <Router>
         <Routes>
            <Route
               path={AppRoute.Index}
               component={() => {
                  return (
                     <div>
                        <Link href={AppRoute.Login}>login</Link>
                     </div>
                  )
               }}
            />
            <Route path={AppRoute.Login} component={LoginPage} />
            <Route path="*" element="[SPA] Not found" />
         </Routes>
      </Router>
   )
}

Entry html:
<!doctype html>
<html>
   <head>
      <meta charset="utf-8" />
      <!--head-->
   </head>
   <body>
      <!--body-->
      <script type="module" src="../pages/index/app-loader.tsx"></script>
   </body>
</html>

and app_loader:
import { render } from 'solid-js/web'
import { App } from '~/app.tsx'
document.body.innerHTML = ''
render(App, document.body)

Video with dev and prod modes:
Was this page helpful?