VSCode React Router Snippets
Simple and Useful Snippets for React Router v7
Configuring Routes
Implement Page
From
Snippet
Renders
R out e
rt
route("pattern", "file"),
I ndex R out e , Ind ex
irt , ind
index("file"),
N ested R out e , Nest ed
nrt , nest
route("parent", "file", [ ]),
L ayout R out e , Lay out
lrt , lay
layout("file", [ ]),
P refix R out e , Pre fix
prt , pre
...prefix("pattern", [ ]),
Imp ort Route Type
imp
import type { Route } from "./+types/...";
L oad er
ld
export async function loader({ ... }) { }
C lient L oad er
cld
export async function clientLoader({ ... }) { }
Ac tion
ac
export async function action({ ... }) { }
C lient Ac tion
cac
export async function clientAction({ ... }) { }
headers()
headers
export function headers() { return { }; }
Route handle
handle
export const handle = { };
links()
links
export function links() { return [ ]; }
meta()
meta
export function meta() { return [ ]; }
s houldR ev alidate
srv
export function shouldRevalidate(arg) { }
R oute C omponent
rc
export default function Component() { }
E rrorB oundary
eb
export function ErrorBoundary() { }
H ydrateF allback
hf
export function HydrateFallback() { }