Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/foxfirecodes/edge-counter

a super minimal repo showing how to write raw edge functions with Vercel
https://github.com/foxfirecodes/edge-counter

Last synced: 5 days ago
JSON representation

a super minimal repo showing how to write raw edge functions with Vercel

Awesome Lists containing this project

README

        

# edge-counter

> a super minimal repo showing how to write raw edge functions with Vercel

## takeaways

- you MUST include `export const config = { runtime: 'edge' }` in your routes. unlike Next.JS, you can't use `export const runtime = 'edge'`. omitting this will result in an API route that just times out.
- you MUST have a non-empty `public` directory. if you don't actually need anything public, just throw an empty file in there to make Vercel happy. for this project I threw some bare-bones HTML in there.
- for some reason, Vercel builds report TypeScript errors that simply aren't real. idk why, but the deployment itself works fine.
- if you want to develop locally (i.e. `vercel dev`), you WILL need to set up a tsconfig. however this isn't technically needed to deploy.
- execution time is around the same as using an edge function in a Next.JS app.

## setup

```bash
# clone the repo
git clone [email protected]:rayzr522/edge-counter.git
cd edge-counter

# install deps
pnpm install

# run vercel's dev server locally
pnpm vercel dev
```