© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3mo ago•
6 replies
Brennan

Edge function shared code

edge functions
Fairly new to edge functions, modularizing some parts and learning about shared code in edge functions. I believe the documentation states that having a _shared folder inside the functions folder and outside any specific function with relative imports
import { x } from "../_shared/x.ts";
import { x } from "../_shared/x.ts";

(https://supabase.com/docs/guides/functions/development-tips#organizing-your-edge-functions)
is the way to utilize shared code. The error in the image
Caused by:
    Module not found "file:///Projects/Programming/work/v2/supabase/functions/_shared/header".
        at file:///Projects/Programming/work/v2/supabase/functions/testing/index.ts:1:24
error running container: exit 1
Try rerunning the command with --debug to troubleshoot the error.
Caused by:
    Module not found "file:///Projects/Programming/work/v2/supabase/functions/_shared/header".
        at file:///Projects/Programming/work/v2/supabase/functions/testing/index.ts:1:24
error running container: exit 1
Try rerunning the command with --debug to troubleshoot the error.

is the result of that syntax. I also read that I need to make an import map in the config.toml to make the function aware of the shared code, I tried this with
[functions]
import_map = "./functions/import_map.json"
[functions]
import_map = "./functions/import_map.json"

to try to make a global import map where I specified
{
  "imports": {
    "shared/": "./_shared/",
    "@supabase/supabase-js": "https://esm.sh/@supabase/supabase-js@2"
  }
}
{
  "imports": {
    "shared/": "./_shared/",
    "@supabase/supabase-js": "https://esm.sh/@supabase/supabase-js@2"
  }
}

to allow all functions to access the shared code. This did not work either...

How can I access my shared code? Thanks!
image.png
Development tips | Supabase Docs
Tips for getting started with Edge Functions.
Development tips | Supabase Docs
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Where do I put shared code in Edge Function?
SupabaseSSupabase / help-and-questions
7mo ago
Deploying Edge Function shared types and Editor errors?
SupabaseSSupabase / help-and-questions
8mo ago
Edge Function
SupabaseSSupabase / help-and-questions
5mo ago
Edge Functions: Failed to load function codeFailed to retrieve function bundle
SupabaseSSupabase / help-and-questions
4mo ago