Is the Airtable.js library compatible with Cloudflare Pages?

We’re trying to get a next.js on Cloudflare pages, and most things are happy, except for trying to invoke Airtable.js library functions: https://github.com/airtable/airtable.js/ from within next.js page files.

Our concern is that the airtable package isn’t in whatever “subset” of NPM packages are available when using nextjs’ “edge-runtime,” a requirement per Cloudflare of non-statically rendered next.js sites: https://nextjs.org/docs/api-reference/edge-runtime

However we can’t find a definitive list of what packages are compatible. We do notice that unless we enable the edge runtime per page, it 404s when we deploy to Cloudflare pages. Each page that can’t be statically rendered requires:

export const config = {
   runtime: 'experimental-edge',
 };

However, if such a page imports Airtable, then, that page crashes next.js’ server with errors about malformed relative URLs. Very weird errors but we think maybe blocks of incompatible with edge-runtime code are being dropped from the airtable library.

For now we’re poking through the library line by line to see if we can find anything that the edge runtime documentation (above) explicitly calls out as unimplemented, but it’d be nice if anyone here could expand and let us know if we’re going down the wrong path or perhaps just tell us if this is impossible / would require forking the airtable library and using implemented APIs.

There’s not any specific list of compatible packages - anything that works in Workers should work with Pages. Common things people run into are Node.js packages that rely on modules not available here.

Honestly though, next-on-pages itself is in a state right now that I couldn’t personally recommend it due to lack of maintenance and support, and would encourage you to consider an alternate solution like Netlify or Vercel for your project if you need a quick resolution.

2 Likes

I swore someone here linked me to this, maybe the reply was deleted? Anyway see also:

https://github.com/cloudflare/next-on-pages/issues/1

In short the answer is basically “no,” because the experimental edge runtime has restrictions that the airtable.js library violates, and, also, env variables apparently aren’t accessible.