Skip to content

Instantly share code, notes, and snippets.

@jacobparis
jacobparis / app\auth.server.ts
Created December 11, 2024 15:56
GitHub Auth
import { invariant } from "@epic-web/invariant"
import { createCookieSessionStorage, redirect } from "@vercel/remix"
import { GitHubProfile, GitHubStrategy } from "remix-auth-github"
import { Authenticator } from "remix-auth"
import { useNavigate } from "@remix-run/react"
invariant(process.env.GITHUB_CLIENT_ID, "GITHUB_CLIENT_ID is not set")
invariant(process.env.GITHUB_CLIENT_SECRET, "GITHUB_CLIENT_SECRET is not set")
invariant(process.env.GITHUB_REDIRECT_URI, "GITHUB_REDIRECT_URI is not set")
invariant(process.env.SESSION_SECRET, "SESSION_SECRET is not set")
@jacobparis
jacobparis / app\cache.server.ts
Last active December 11, 2024 11:23
Cachified
import {
cachified as baseCachified,
type CacheEntry,
type Cache,
totalTtl,
type CachifiedOptions,
verboseReporter,
} from '@epic-web/cachified';
import { remember } from '@epic-web/remember';
import { LRUCache } from 'lru-cache';
@jacobparis
jacobparis / app\components\icon.tsx
Last active December 11, 2024 11:24
React Icon component
import { type IconName } from "#app/components/icons/icons.ts"
import href from "#app/components/icons/sprite.svg"
export function Icon({
name,
className,
...props
}: React.SVGProps<SVGSVGElement> & {
name: IconName
}) {
@jacobparis
jacobparis / _patch issue
Last active July 26, 2024 23:53
The final hunk in this patch fails and I don't know why
patch package.json < package.json.patch
@jacobparis
jacobparis / timing.server.ts
Created April 29, 2023 23:24
Server Timing Utilities for Remix
export type PerformanceServerTimings = Record<
string,
Array<PerformanceServerTiming>
>
/**
* Run this on the server to get a `time` function that can be used to time
* server-side operations and add them to the `Server-Timing` header.
*/
export function getServerTiming() {

remix-route-extensions

This package allows you to specify .route.tsx files anywhere in your /app directory and they will be recognized as routes

Filenames follow the v2 flat routes convention

root.tsx
app
  _layout.route.tsx
@jacobparis
jacobparis / @remix-run+dev+1.15.0.patch
Last active April 27, 2023 21:30
Remix feature folders patch-package
diff --git a/node_modules/@remix-run/dev/dist/compiler/assets.js b/node_modules/@remix-run/dev/dist/compiler/assets.js
index b01942f..8f90ae1 100644
--- a/node_modules/@remix-run/dev/dist/compiler/assets.js
+++ b/node_modules/@remix-run/dev/dist/compiler/assets.js
@@ -95,6 +95,7 @@ async function createAssetsManifest({
routes,
hmrRoutes: hmr === null || hmr === void 0 ? void 0 : hmr.routes
})).slice(0, 8);
+
return {
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@jacobparis
jacobparis / machine.js
Last active April 5, 2020 02:53
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions