TanStackT
TanStack12mo ago
7 replies
developed-pink

How to read request object for a route?

Hello, I was wondering what is the correct approach for reading the request object for a route? In react router you would do something like:

import { LoaderFunctionArgs, redirect } from 'react-router';
import { parse } from 'cookie';

export async function loader({ request }: LoaderFunctionArgs) {
  const cookie = request.headers.get('cookie');

  const accessToken = parse(cookie || '').accessToken;

  if (!accessToken) {
    return redirect('/login/email');
  }

  return redirect('/profile');
}


Whats the equivalent of this in tanstack router? I scoured the documentation but couldnt find a resource on how exactly I can read the request object.
Was this page helpful?