AI summary by TwinMind

I'm Coming Around To Remix...

Theo - t3․gg

35m 8s

Framework Philosophy & Use Cases

  • Speaker not biggest Remix proponent but acknowledges it does many things well
  • Created diagram showing framework sweet spots:
    • React: mostly static to dynamic web apps
    • Next.js: mostly static but loads JavaScript, enables client-side updates + SSR
    • Remix: past where React goes, enables truly static JavaScript-free websites using React server-side
    • Astro: strong in static to static generated, developing SSR story
  • Remix criticized for not making dynamic development easy (no hot module reloading, full page reloads required)
  • Next.js recommended for dynamic web apps needing static rendering + API close to client

Growth Book Feature Flag Implementation

  • Growth Book: feature flag solution similar to LaunchDarkly
  • Simple API: install module, provide URL, define features in JSON
  • React usage: useFeature('newLoginForm').on or useFeature('loginButtonColor')
  • API criticism: pattern of chaining after hook (.on) uncommon in React, causes developer mistakes
    • Engineers forget .on part, check against object instead of boolean value
    • No type error because object is truthy
    • Recommend traditional React pattern: const [value] = useFeature() or selector pattern

Server-Side Rendering Challenge

  • Goal: put new pricing page under feature flag
  • Problem: loading JSON client-side means server renders incorrect page initially
    • Server doesn't know feature flag state until after first paint
    • Results in flicker from old page to new page for users in experiment
  • Solution needed: server-side render feature flags so first page load is correct based on user's flags

Next.js Implementation Problems

  • Created helper function getSessionAndFeatureFlags() returning session + growth book config
  • Issues encountered:
    • Cannot easily get origin with http/https on server-side
    • Had to use ternary hack for environment detection
    • No way to get context.request.headers with proper origin before path
    • Type safety problems: page props are any typed throughout
    • Complex data flow between getServerSideProps and app component

Next.js Data Flow Analysis

  • Request lifecycle: User request → Site rendered on device
  • Execution order:
    1. _middleware.tsx (first)
    2. _document.tsx
    3. Page component + getServerSideProps
    4. _app.tsx
  • Data flow jumps between files losing type safety
  • getServerSideProps runs before _app.tsx but data must pass through app to reach page component
  • Unintuitive pattern: function and its data fetching in same file but huge execution gap between them

Feature Flag Provider Implementation

  • Provider lives in app.tsx, data fetching in individual pages
  • Complex typing due to any page props
  • Growth book instantiation with features from page props + session attributes
  • Fallback useEffect for client-side fetch if no server props
  • Attribute manager for dynamic bucketing (user slug changes, staff status)

Remix Implementation Advantages

  • Much simpler data flow: loader → component (same file, direct connection)
  • Root loader example:
      // In root loader
      const data = await fetch(growthBookUrl);
      
      // In component  
      const growthBookData = useLoaderData();
  • Can add loader to any route level (root, index, nested routes)
  • Data fetching co-located with component using the data
  • Runs on edge, better performance for route-level data needs

Type Safety Criticisms

  • Both Next.js and Remix lack proper type inference between data fetching and components
  • Remix example: loader returns {hello: "world"} but useLoaderData() returns any
  • No automatic connection between loader function and component types
  • Proposed solutions:
    • typeof loader type inference
    • Passing loader function to useLoaderData<typeof loader>()
    • Compiler-based type generation
  • Author's preference: require passing loader to useLoaderData for type safety
  • Zod creator (Colin) has PR for better type inference in Remix

Framework Comparison Summary

  • Next.js solutions feel "tacked on", new layouts RFC is step in right direction
  • Remix stronger for initial page data, weaker for complex application development
  • Both frameworks have type safety issues with server/client data boundary
  • Remix's co-located loader pattern more intuitive than Next.js's scattered data flow
  • Edge deployment advantages in Remix for route-level data fetching

Community & Future Outlook

  • Appreciates Remix community, critical of top-down marketing approach
  • References old Ryan Florence tweet about Remix handling "initial and transition page data" as correct positioning
  • Seeing more value in Remix patterns despite application development concerns
  • Next.js middleware improvements expected, file-based routing for middleware not ideal

TwinMind

Get summaries like this for your own meetings

TwinMind takes notes in the background during meetings, lectures, and calls, then writes the summary for you.

Free plan to get started

No bot joins your calls

Phone, desktop & Chrome apps

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome