# WeWeb / Supabase - Refresh Session

**URL:** <https://community.weweb.io/t/weweb-supabase-refresh-session/21046>\
**Category:** Ask us anything\
**Created:** [April 12, 2026, 5:57pm UTC](https://community.weweb.io/t/weweb-supabase-refresh-session/21046 "2026-04-12T17:57:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxi](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@maxi](https://community.weweb.io/u/maxi)\
**Post date:** [April 12, 2026, 5:57pm UTC](https://community.weweb.io/t/weweb-supabase-refresh-session/21046/1 "2026-04-12T17:57:53Z")

</div>

Please help!

I’m working with Supabase and use the new “Data&API” Tab, so I dont have any plugins installed.

A user can have multiple tenants and therefore I store the tenants ID in my JWT (app\_metadata).

I use a invoke edge function in order to switch the tenant and store the tenant\_id in the JWT - BUT - after that I need to refresh the session in order to use that new tenant id but I simply can’t refresh the session as the new native Supabase integration doesn’t give the function “refresh”.

If I now use the Supabase auth plugin in order to get the refresh session, I can’t access the invoke edge function anymore. it’s a nightmare.

also I tried custom JS in order to refresh but I always get an error as apparently weweb changed a lot of its editor architecture?!

this is the JS code:

```auto

// Get the Supabase integration instance
const supabase = wwLib.getIntegration(‘supabase’).instance;

// Force a session refresh to retrieve the updated JWT with new tenant claims
const { data, error } = await supabase.auth.refreshSession();

if (error) {
wwLib.log.error(‘Failed to refresh session:’, error.message);
throw error;
}

return data.session;

```

(its from we webs ai, but similar to gemini and gpt)

the “bulletproof js that should DEFINITELY work (haha ): ) is this one:

```auto
try {
// 1. Locate the Supabase Auth instance
// WeWeb typically uses ‘supabaseAuth’ or ‘supabase’ as the plugin ID
const supabasePlugin = wwLib.wwPlugins.supabaseAuth || wwLib.wwPlugins.supabase;

if (!supabasePlugin || !supabasePlugin.instance) {
    throw new Error('Supabase integration not found. Please ensure the Supabase Auth plugin is installed.');
}

const supabase = supabasePlugin.instance;

// 2. Force a session refresh
// This calls the Supabase API to exchange the refresh token for a new access token
// containing the updated 'app_metadata' (the new tenant claims).
const { data, error } = await supabase.auth.refreshSession();

if (error) {
    wwLib.log.error('Supabase Refresh Error:', error.message);
    return { success: false, error: error.message };
}

// 3. Update the global session context in WeWeb
// This ensures that subsequent requests use the new JWT
return {
    success: true,
    session: data.session,
    accessToken: data.session.access_token
};

} catch (err) {
wwLib.log.error(‘Workflow JS Error:’, err.message);
throw err;
}

```

Anyone can help me with this one? feels like the new weweb + Supabase is not too recommendable.

---

<div class="post-metadata">

**Author:** ![Joyce](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/joyce/32/13232_2.png) [@Joyce](https://community.weweb.io/u/Joyce)\
**Post date:** [April 13, 2026, 12:37pm UTC](https://community.weweb.io/t/weweb-supabase-refresh-session/21046/2 "2026-04-13T12:37:30Z")

</div>

Hey @maxi 👋

Refresh sessions are managed automatically with the new Supabase integration.

Can you try without any custom code? It should work out of the box. If not, can you share a short video walkthrough of how things are setup on your side and where the flow breaks down?

---

<div class="post-metadata">

**Author:** ![maxi](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@maxi](https://community.weweb.io/u/maxi)\
**Post date:** [April 13, 2026, 12:51pm UTC](https://community.weweb.io/t/weweb-supabase-refresh-session/21046/3 "2026-04-13T12:51:25Z")

</div>

Thank you so much for the clarification. Unfortunately, it still doesn’t work. I’ll send you the screen recording.

---

<div class="post-metadata">

**Author:** ![Joyce](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/joyce/32/13232_2.png) [@Joyce](https://community.weweb.io/u/Joyce)\
**Post date:** [April 13, 2026, 1:06pm UTC](https://community.weweb.io/t/weweb-supabase-refresh-session/21046/4 "2026-04-13T13:06:21Z")

</div>

Thanks for taking the time to put a video together @maxi !

Let me see if I understand correctly:

- in the UI, admins can select a different company/tenant
- when that different company is selected, you want to trigger a workflow that invokes an edge function (to update the selected company/tenant), wait 1000ms and then fetch a user based on the response returned by the edge function

Is that correct?

---

<div class="post-metadata">

**Author:** ![maxi](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@maxi](https://community.weweb.io/u/maxi)\
**Post date:** [April 13, 2026, 1:20pm UTC](https://community.weweb.io/t/weweb-supabase-refresh-session/21046/5 "2026-04-13T13:20:38Z")

</div>

Thank you so much for answering 😃

It’s a multi tenancy SaaS, so I have a user that is assigned to one or many tenants. based on that tenant, I fetch the data that relate to the current active tenant.

so, if I click on the menu and switch tenant, I have that edge function triggered that basically says active tenant = inputs value, authenticate with the bearer key… then in the db the active tenant gets updated (is\_active=true) and the active tenants id gets saved in the users JWT.

I hope you could understand haha

What happens then is that I need to manually refresh the session in order to get the updated JWT, as PROBABLY the edge function doesn’t trigger the auto session refresh…. (thats my guess for now).

---

<div class="post-metadata">

**Author:** ![Joyce](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/joyce/32/13232_2.png) [@Joyce](https://community.weweb.io/u/Joyce)\
**Post date:** [April 14, 2026, 2:45pm UTC](https://community.weweb.io/t/weweb-supabase-refresh-session/21046/6 "2026-04-14T14:45:04Z")

</div>

> [@maxi](#):
>
> so, if I click on the menu and switch tenant, I have that edge function triggered that basically says active tenant = inputs value, authenticate with the bearer key… then in the db the active tenant gets updated (is\_active=true) and the active tenants id gets saved in the users JWT.

Okayyyy I _think_ I understand the use case now but I’m not sure what the best approach would be. Let me ask the tech team for their thoughts on this and get back to you 🙂

---

<div class="post-metadata">

**Author:** ![RPAL](https://avatars.discourse-cdn.com/v4/letter/r/85f322/32.png) [@RPAL](https://community.weweb.io/u/RPAL)\
**Post date:** [July 1, 2026, 1:34am UTC](https://community.weweb.io/t/weweb-supabase-refresh-session/21046/7 "2026-07-01T01:34:14Z")

</div>

> [@maxi](#):
>
> `const supabase = wwLib.getIntegration(‘supabase’).instance;`

Is this the correct equivalent to the old…

```auto
const supabase = wwLib.wwPlugins.supabase.instance;
```

I am looking into the new supabase integration but I have custom js that needs access to the supabase client. @Joyce

---

<div class="post-metadata">

**Author:** ![Joyce](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/joyce/32/13232_2.png) [@Joyce](https://community.weweb.io/u/Joyce)\
**Post date:** [July 1, 2026, 9:50am UTC](https://community.weweb.io/t/weweb-supabase-refresh-session/21046/8 "2026-07-01T09:50:13Z")

</div>

Hey @RPAL 👋

You can’t access the Supabase integration instance right now. We have a product ticket for it but development work hasn’t started yet.

Would you mind sharing a bit more about your use case? I’d love to know if there’s an opportunity for a native feature that removes the need for custom code in the future.

---

<div class="post-metadata">

**Author:** ![Joyce](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/joyce/32/13232_2.png) [@Joyce](https://community.weweb.io/u/Joyce)\
**Post date:** [August 4, 2026, 9:27am UTC](https://community.weweb.io/t/weweb-supabase-refresh-session/21046/9 "2026-08-04T09:27:34Z")

</div>

Hey there 👋

Just wanted to let you know we just added the “Refresh token” action to the Supabase integration 🙂

 ![CleanShot 2026-08-04 at 11.26.14@2x](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/3X/6/4/64bc8ed806750be220dd1c71a39105727289f416.png)
