Remix Utils - v9.3.1
    Preparing search index...

    Module Server/Responses

    Note

    Install using bunx shadcn@latest add @remix-utils/responses.

    Note

    Install using bunx shadcn@latest add @remix-utils/redirect-back.

    This function is a wrapper of the redirect helper from Remix. Unlike Remix's version, this one receives the whole request object as the first value and an object with the response init and a fallback URL.

    The response created with this function will have the Location header pointing to the Referer header from the request, or if not available, the fallback URL provided in the second argument.

    import { redirectBack } from "remix-utils/redirect-back";

    export async function action({ request }: Route.ActionArgs) {
    throw redirectBack(request, { fallback: "/" });
    }

    This helper is most useful when used in a generic action to send the user to the same URL it was before.

    Note

    Install using bunx shadcn@latest add @remix-utils/responses.

    Helper function to create a Not Modified (304) response without a body and any header.

    import { notModified } from "remix-utils/responses";

    export async function loader({ request }: Route.LoaderArgs) {
    return notModified();
    }
    Note

    Install using bunx shadcn@latest add @remix-utils/responses.

    Helper function to create a JavaScript file response with any header.

    This is useful to create JS files based on data inside a Resource Route.

    import { javascript } from "remix-utils/responses";

    export async function loader({ request }: Route.LoaderArgs) {
    return javascript("console.log('Hello World')");
    }
    Note

    Install using bunx shadcn@latest add @remix-utils/responses.

    Helper function to create a CSS file response with any header.

    This is useful to create CSS files based on data inside a Resource Route.

    import { stylesheet } from "remix-utils/responses";

    export async function loader({ request }: Route.LoaderArgs) {
    return stylesheet("body { color: red; }");
    }
    Note

    Install using bunx shadcn@latest add @remix-utils/responses.

    Helper function to create a PDF file response with any header.

    This is useful to create PDF files based on data inside a Resource Route.

    import { pdf } from "remix-utils/responses";

    export async function loader({ request }: Route.LoaderArgs) {
    return pdf(await generatePDF(request.formData()));
    }
    Note

    Install using bunx shadcn@latest add @remix-utils/responses.

    Helper function to create a HTML file response with any header.

    This is useful to create HTML files based on data inside a Resource Route.

    import { html } from "remix-utils/responses";

    export async function loader({ request }: Route.LoaderArgs) {
    return html("<h1>Hello World</h1>");
    }
    Note

    Install using bunx shadcn@latest add @remix-utils/responses.

    Helper function to create a XML file response with any header.

    This is useful to create XML files based on data inside a Resource Route.

    import { xml } from "remix-utils/responses";

    export async function loader({ request }: Route.LoaderArgs) {
    return xml("<?xml version='1.0'?><catalog></catalog>");
    }
    Note

    Install using bunx shadcn@latest add @remix-utils/responses.

    Helper function to create a TXT file response with any header.

    This is useful to create TXT files based on data inside a Resource Route.

    import { txt } from "remix-utils/responses";

    export async function loader({ request }: Route.LoaderArgs) {
    return txt(`
    User-agent: *
    Allow: /
    `);
    }

    Type Aliases

    ImageType

    Functions

    html
    image
    javascript
    notModified
    pdf
    stylesheet
    txt
    xml