Skip to content

Instantly share code, notes, and snippets.

View brandonpittman's full-sized avatar

Brandon Pittman brandonpittman

View GitHub Profile
// root.tsx
import { getUserSession, requireUser, logout } from "~/session";
export function loader({ request }) {
// use case: know if the user is logged in, no redirect to /login
let userSession = await getUserSession(request);
let isAuthenticated = userSession.has("userId");
return { isAuthenticated };
}
@na2hiro
na2hiro / Remix-request-cheatsheet.md
Last active February 8, 2025 03:16
Remix request cheatsheet
@brandonpittman
brandonpittman / use-presence-with-tailwind.tsx
Last active February 1, 2024 04:23
`usePresence` with Tailwind animation utilities
import { AnimatePresence, usePresence } from "framer-motion";
import { classNames } from "~/lib/utils/class-names";
import { useCounter } from "@kyleshevlin/use-common";
import { useCallback } from "react";
const Box = ({ count }: { count: number }) => {
const [isPresent, safeToRemove] = usePresence();
const onAnimationEnd = useCallback(() => {
if (!isPresent) safeToRemove();