Remix/Single Fetch/Redirect To Response
Codemod verified
Regularly tested and maintained by our engineers and codemod expert community.
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 = 302response.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