Remix/Single Fetch/Redirect To Response

1.0.0Last update Jul 24, 2024
by@jacobparis
Remix-run/react

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