© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•2w ago•
7 replies
Prabhav

Supabase-Clerk Integration JWT Expiry

auth
NextJS Application hosted on Vercel
Clerk for Auth, Supabase for database/object storage
Clerk-Supabase Integration has been set up, as per: https://supabase.com/docs/guides/auth/third-party/clerk
https://clerk.com/docs/guides/development/integrations/databases/supabase

When a call is made to the backend, the following high-level steps are performed:
1. Authenticate the user using clerk auth()
2. Read from the database.
3. Backend performs its operation.
4. Write results to the database.
5. Return.

For step 3, short-running tasks (<30s) work perfectly. Longer tasks (currently ranging up to 5-6 minutes), throw an error at step 4.

Upload a file to object storage: “Error: Storage upload failed: "exp" claim timestamp check failed”
Write to a table in the database: “Error: Failed to add message: JWT expired”

Our Supabase client instantiation code:

export function getSupabaseClient() {
  return createClient<Database>(
    NEXT_PUBLIC_SUPABASE_URL,
    NEXT_PUBLIC_SUPABASE_ANON_KEY,
    {
      async accessToken() {
        return (await auth()).getToken();
      },
      auth: {
        persistSession: false,
        autoRefreshToken: false,
      },
    }
  );
}
export function getSupabaseClient() {
  return createClient<Database>(
    NEXT_PUBLIC_SUPABASE_URL,
    NEXT_PUBLIC_SUPABASE_ANON_KEY,
    {
      async accessToken() {
        return (await auth()).getToken();
      },
      auth: {
        persistSession: false,
        autoRefreshToken: false,
      },
    }
  );
}


Through our testing, we have verified that Supabase is using an expired token during its final write. We tried instantiating a new Supabase client for the final write and it ends up using the same token. Is there a way to refresh this token from the server? Is there a way to increase this token’s timeout? Is there another way around this problem?

Referenced Documentation:
• https://clerk.com/docs/guides/sessions/session-tokens
• https://supabase.com/docs/reference/javascript/initializing

We would appreciate any information or guidance with regards to this issue. Please let me know if there is any more information I can provide. Thank you!
Clerk | Supabase Docs
Use Clerk with your Supabase project
Clerk | Supabase Docs
Clerk
Integrate Supabase with Clerk - Databases | Clerk Docs
Learn how to integrate Clerk into your Supabase application.
Integrate Supabase with Clerk - Databases | Clerk Docs
Clerk
Session tokens - Session management | Clerk Docs
Learn about session tokens and how to validate them in your backend.
Session tokens - Session management | Clerk Docs
JavaScript: Initializing | Supabase Docs
Supabase API reference for JavaScript: Initializing
JavaScript: Initializing | 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

Clerk integration with supabase storage
SupabaseSSupabase / help-and-questions
2mo ago
Clerk/Supabase React-native Integration
SupabaseSSupabase / help-and-questions
8mo ago
JWT Refresh Token Expiry Settings
SupabaseSSupabase / help-and-questions
7mo ago
Supabase with Clerk
SupabaseSSupabase / help-and-questions
3d ago