+
Tasks
- if (error) {
- return
Error: {JSON.stringify(error, null, 2)}
;
- }
+ {loading &&
Loading...
}
- return null;
- }
- ```
-
-1. Finally, edit your component to return a basic UI that allows you to list all your addresses:
-
- ```ts filename="app/supabase/page.tsx"
- return (
-
-
Addresses
- {!data ? (
-
No addresses
- ) : (
-
- {data.map((address: any) => (
- - {address.content}
- ))}
-
- )}
-
- );
- }
- ```
-
-1. The final result should be similar to this:
- ```ts filename="app/supabase/page.tsx"
- import { auth } from "@clerk/nextjs/server";
- import { CookieOptions, createServerClient } from "@supabase/ssr";
- import { cookies } from "next/headers";
-
- async function createClerkSupabaseClient() {
- const cookieStore = cookies();
- const { getToken } = auth();
-
- const token = await getToken({ template: "supabase" });
- const authToken = token ? { Authorization: `Bearer ${token}` } : null;
-
- return createServerClient(
- process.env.NEXT_PUBLIC_SUPABASE_URL!,
- process.env.NEXT_PUBLIC_SUPABASE_KEY!,
- {
- global: { headers: { "Cache-Control": "no-store", ...authToken } },
- cookies: {
- get(name: string) {
- return cookieStore.get(name)?.value;
- },
- set(name: string, value: string, options: CookieOptions) {
- try {
- cookieStore.set({ name, value, ...options });
- } catch (error) {
- // Handle the error
- }
- },
- remove(name: string, options: CookieOptions) {
- try {
- cookieStore.set({ name, value: "", ...options });
- } catch (error) {
- // Handle the error
- }
- },
- },
- }
- );
- }
-
- export default async function Supabase() {
- const client = await createClerkSupabaseClient();
-
- const { data, error } = await client.from("Addresses").select();
+ {!loading &&
+ tasks.length > 0 &&
+ tasks.map((task: any) =>
{task.name}
)}
- if (error) {
- return
Error: {JSON.stringify(error, null, 2)}
;
- }
+ {!loading && tasks.length === 0 &&
No tasks found
}
- return (
-
-
Addresses
- {!data ? (
-
No addresses
- ) : (
-
- {data.map((address: any) => (
- - {address.content}
- ))}
-
- )}
-
- );
- }
- ```
+
+
+ );
+}
+```
-1. Try out your application. When you visit the page with your component, you'll be required to sign in. Try creating and fetching content.
+### Test your integration
-