Comments (2)
Hi, I would like to add on this.
In "Step 5: Set auth token with Supabase", it is mentioned to use supabase.auth.setAuth(token)
.
Unfortunately this method is not available anymore, and I'm not sure what's the next step.
The error I'm seeing in my editor:
I've used both Supabase and Clerk's documentation on this integration, none are working at the moment.
Edit: The docs stated this setAuth
is now deprecated. Would appreciate on updating this, as I still haven't found a way yet to set this up.
Edit 2:
The official docs in Clerk is the solution:
https://clerk.com/docs/integrations/databases/supabase#fetch-supabase-data-in-your-code
Only caveat is you need to import useRef
and useState
from react, otherwise the token would be undefined
as it wasn't hydrated yet.
from supabase.
Hi, I would like to add on this.
In "Step 5: Set auth token with Supabase", it is mentioned to use
supabase.auth.setAuth(token)
.
Following up to this, I just found a solution, but it feels hacky. Each time we need to call supabase, I made it to accept token as a param.
export const supabase = (clerkToken: string) =>
createClient<Database>(
process.env.NEXT_PUBLIC_SUPABASE_URL ?? "",
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY ?? "",
{
global: {
fetch: async (url, options = {}) => {
const headers = new Headers(options?.headers);
headers.set("Authorization", `Bearer ${clerkToken}`);
return fetch(url, {
...options,
headers,
});
},
},
},
);
"use client";
export default function Component() {
const { getToken } = useAuth();
const [token, setToken] = useState('');
// Where the magic happen, and leveraging useState
const myQuery = supabase(token).from('my_table').select();
useEffect(() => {
const token = await getToken();
if (!token) return;
setToken(token);
const data = await myQuery;
// continue with your data
}, []}
}
The problem with official docs using window.Clerk?.session.getToken()
is that the token was null at first. Only once its fully loaded, we can leverage the token (thus the above solution).
from supabase.
Related Issues (20)
- When reading a declared vaiable (once initialized from a jsonb input) in a database function (in plpgsql) gives another value when read from nested blocks HOT 1
- When I do a db pull it drops mfa_factors_last_challenged_at_key and this cause the application to break
- API Settings Page redirects to default home page in self hosted docker HOT 6
- .RedirectTo not being respected at Email template on href
- Unable to send any email HOT 1
- 401 error when upload file to selfhost instance HOT 1
- Word 'compute' is there twice on Pricing & Fees page HOT 2
- Authentication failure in Graphiql - Self Host Docker HOT 8
- Upload video times error, try picture resources normal, through the management panel HOT 1
- Turnstile captcha is being bypassed on signUp
- Confusing OIDC login instructions.
- [@supabase/ssr] - [SvelteKit]: Create A Client: Missing typescript documentation
- you really should disclose about what features are available on self hosted vs paid so people wont waste their time on supabase
- you really should disclose about what features are available on self hosted vs paid so people wont waste their time on supabase HOT 1
- Can't create user in Supabase dashboard after running supabase db reset --linked HOT 1
- Unable to Connect to Supabase PostgreSQL via Sequelize: SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing HOT 14
- "Permission denied for schema extensions" - Using webhooks with Postgis HOT 1
- Enabling Supabase Auth Hook for send-email locally causes a 500 during call to supabase.auth.signUp HOT 14
- Bug in auth hook password verification example HOT 1
- AuthRetryableFetchError on supabase.auth.signUp in NextJS HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from supabase.