Remix-run/react
byjacobparis

Remix/Single Fetch/Redirect To Response

/icons/calendar.svg

Last update

Jul 24, 2024

Remix / Single Fetch / Redirect to response

This codemod removes Remix's redirect() and redirectDocument() helper functions to take advantage of the new Single Fetch features.

Usage

You can use this codemod with the following command:

codemod remix/single-fetch/redirect-to-response

Examples

Input:

export async function loader({ request }: LoaderFunctionArgs) {
const user = await getUser(request)
if (!user) {
throw redirect('/login')
}
return user
}

Output:

export async function loader({ request, response }: LoaderFunctionArgs) {
const user = await getUser(request)
if (!user) {
response.status = 302
response.headers.set('Location', '/login')
throw response
}
return user
}

Build custom codemods

Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community

background illustrationGet Started Now