Add a page

Serve a brand-new URL, such as /faq, from your theme.

Framework: TanStack Start

This page is written for TanStack Start, the default and currently supported framework. See what depends on the framework.

Use this when the storefront needs a URL the engine does not have. This is the short version; Add a custom route covers loaders, titles and loading states.

Goal: /faq (and /ar/faq, /en/faq) shows your page.

Declare the path

app/routes.ts
import { route } from '@tanstack/virtual-file-routes';

export const routes = [route('/faq', 'faq.tsx')];

Write the route file

The createFileRoute path is the same URL with the optional {-$locale} prefix in front.

app/routes/faq.tsx
import { createFileRoute } from '@tanstack/react-router';
import { useTranslation } from '@salla.sa/twilight-theme-engine/i18n';

function FaqPage() {
  const { t } = useTranslation();
  return (
    <div className="container">
      <h1>{t('pages.faq.title', 'Frequently asked questions')}</h1>
    </div>
  );
}

export const Route = createFileRoute('/{-$locale}/faq')({
  head: () => ({ meta: [{ title: 'FAQ' }] }),
  component: FaqPage,
});

Restart and open it

Restart the dev server so the route tree is regenerated, then open /faq. Add the pages.faq.title key to both locale files: Add translation keys.

Check it worked

/faq and /ar/faq both render the heading. If one gives a 404, see the traps.

Traps

  • A 404 right after adding the route means the route tree is stale. Restart the dev server.
  • Forgetting {-$locale} in the createFileRoute path makes the page unreachable under /ar/... and /en/....
  • Never put // @auto-generated at the top of a route file you wrote. The plugin treats that marker as disposable and overwrites the file on the next build.
  • Dynamic segments use TanStack syntax: route('/promotions/$id', 'promotions.$id.tsx'). Read the value with Route.useParams().

Next

On this page