import { redirect, type LoaderArgs } from '@remix-run/node' import { routerPaths, type RouterParams, type RouterPath } from '../routes' const THIS_PATH = '/my/:awesome?/route' satisfies RouterPath export async function loader(args: LoaderArgs) { // Can type params const params = args.params as RouterParams[typeof THIS_PATH] // params.awesome?: string | undefined | null const count = Number(params.awesome) || 0 // Can build path with params return redirect(routerPaths[THIS_PATH]({ awesome: count + 1 })) }