Convex actions are the simplest way to interact with the world beyond the database but they can't currently be used to build HTTP APIs. Instead we recommend building your public HTTP API on top of the serverless functions from a hosting provider like Netlify or Vercel.
The steps below include information for both Netlify and Vercel, but should be applicable to any hosting provider supporting functions.
Both Netlify and Vercel support local development environments for testing out your local functions. As a first step, let's set up the local environment:
npm install -g netlify-cli
npm install -g vercel
We'll assume you're already running
npx convex dev. Ordinarily if you wanted
to run the web client locally you'd run
npm run dev but now you can run the
client within a simulated hosted environment instead by running:
You can fire up
netlify dev or
vercel dev alongside
npx convex dev.
S3 photo upload demo
for examples of the code in
api/ directory that defines externally hosted API
If you followed the tutorial on hosting and deployment then
deployment is as simple as committing your changes to your repository and
git push! Netlify and Vercel automatically watch your repository for
changes and publish these to your production site.