Skip to content

netlify-labs/remix-edge-api-caching

Repository files navigation

Fast Edge Rendering with Remix

Edge rendering can be fast if combined with edge API caching. This is a simple example of using Remix with edge rendering and Netlify Functions as a backend for the front-end that uses stale-while-revalidate to keep API responses fast at the edge.

It renders a plain list of the latest stories from Hacker News. In app/_index.tsx a loader fetches the storeis from a Netlify Function. The function uses the Stale While Revalidate approach to keep responses fast and cached at the edge when deployed to Netlify.

Read more about the approach in this guide to Fast Edge Rendering with API Caching

Netlify Setup

  1. Install the Netlify CLI:
npm i -g netlify-cli

If you have previously installed the Netlify CLI, you should update it to the latest version:

npm i -g netlify-cli@latest
  1. Sign up and log in to Netlify:
netlify login
  1. Create a new site:
netlify init

Development

Ensure all packages are installed by running:

npm install

Run

netlify dev

Open up http://localhost:8888, and you're ready to go!

Serve your site locally

To serve your site locally in a production-like environment, run

netlify serve

Your site will be available at http://localhost:8888. Note that it will not auto-reload when you make changes.

Deployment

There are two ways to deploy your app to Netlify, you can either link your app to your git repo and have it auto deploy changes to Netlify, or you can deploy your app manually. If you've followed the setup instructions already, all you need to do is run this:

# preview deployment
netlify deploy --build

# production deployment
netlify deploy --build --prod

About

Demo of remix edge rendering with Netlify and API caching

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published