Multi-file Edge Functions with shared code

Real-world Edge Function projects rarely live in a single file. You might have three functions that all use the same CORS headers, the same response helper, or the same JWT validation logic. The Supabase CLI handles this with --import-map and shared utilities in a _shared folder. BaseDeck handles it the same way — from your phone, with the import paths resolved automatically by the bundle engine.

How multi-file deployment works

When you switch to Multi-file mode and add files, BaseDeck sends all of them to the server-side bundle endpoint together. The bundle engine (running as a Netlify Edge Function written in Deno/TypeScript) resolves local import paths — it reads each file, finds any relative imports like import { cors } from "../_shared/cors.ts", and includes the referenced files in the deployment bundle. This replicates the Supabase CLI's bundling behaviour without needing a terminal or a local file system.

Project structure example

Here's a typical layout for a multi-file project. You'll add each of these files to BaseDeck manually:

functions/
  hello/
    index.ts          ← entry point
  goodbye/
    index.ts          ← another function
  _shared/
    cors.ts           ← shared CORS helper
    response.ts       ← shared response utilities

The shared files live outside the individual function folders. Each function imports from them using relative paths.

Example shared utility

// _shared/cors.ts
export const corsHeaders = {
  "Access-Control-Allow-Origin": "*",
  "Access-Control-Allow-Headers": "authorization, x-client-info, apikey, content-type",
};
// hello/index.ts
import { serve } from "https://deno.land/std@0.168.0/http/server.ts"
import { corsHeaders } from "../_shared/cors.ts"

serve(async (req: Request) => {
  if (req.method === "OPTIONS") {
    return new Response("ok", { headers: corsHeaders })
  }
  const { name } = await req.json()
  return new Response(
    JSON.stringify({ message: `Hello ${name}!` }),
    { headers: { ...corsHeaders, "Content-Type": "application/json" } }
  )
})

Deploying from BaseDeck

1

Open the deploy screen https://basedeck.netlify.app/dashboard

In the Functions tab, tap + Deploy. On the mode selector, choose Multi-file.

2

Add your files

Tap Add file to add files one by one, or tap Select folder to pick an entire folder from your device storage. Each file opens in a separate editor tab. You can switch between them and edit any file before deploying.

3

Set the entry point

Tap the star icon on the file that is the function's main entry point (e.g. index.ts). The entry file is what Supabase runs when the function is invoked — the other files are supporting modules.

4

Set the function name

Enter the function slug. This becomes the URL path at supabase.co/functions/v1/your-slug.

5

Deploy

Tap Deploy. The bundle engine resolves all imports across your files and deploys the complete function set. Watch the deploy log panel for real-time output from the server.

If you have multiple functions in the same project that share utilities, you can deploy them all in one session — each gets its own entry point file, and the shared files are included in all relevant bundles.

Reading the deploy log

The deploy log panel shows every step: file transmission, bundle resolution, Supabase API call, and final confirmation. If a deployment fails, the error is highlighted in red with the message from the Supabase API. Common issues are incorrect import paths (check that relative paths in your files match exactly what you named each file in BaseDeck) and missing entry point selection.