0
0
Supabasecloud~10 mins

Session management in Supabase - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize Supabase client with session persistence.

Supabase
const supabase = createClient(supabaseUrl, supabaseKey, { auth: { persistSession: [1] } });
Drag options to blanks, or click blank then click option'
Atrue
Bundefined
Cnull
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using false disables session persistence, so user sessions won't be saved.
Using null or undefined will cause errors or default behavior.
2fill in blank
medium

Complete the code to get the current user session from Supabase auth.

Supabase
const session = await supabase.auth.[1]();
Drag options to blanks, or click blank then click option'
AgetSession
BgetUser
CfetchSession
DcurrentSession
Attempts:
3 left
💡 Hint
Common Mistakes
Using getUser returns user info, not the full session.
fetchSession and currentSession are not valid Supabase auth methods.
3fill in blank
hard

Fix the error in the code to listen for auth state changes and update session.

Supabase
supabase.auth.onAuthStateChange((event, [1]) => { session = [1]; });
Drag options to blanks, or click blank then click option'
AsessionData
Bsession
CuserSession
DauthSession
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name not matching the callback parameter causes reference errors.
Confusing event and session parameters.
4fill in blank
hard

Fill both blanks to sign in a user with email and password using Supabase auth.

Supabase
const { data, error } = await supabase.auth.[1]({ email: userEmail, [2]: userPassword });
Drag options to blanks, or click blank then click option'
AsignInWithPassword
BsignUp
Cpassword
Dpass
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'signUp' instead of 'signInWithPassword' signs up a new user.
Using 'pass' instead of 'password' causes authentication failure.
5fill in blank
hard

Fill all three blanks to refresh the session token manually using Supabase auth.

Supabase
const { data, error } = await supabase.auth.[1](); if (!error) { const newAccessToken = data.[2].[3]; }
Drag options to blanks, or click blank then click option'
ArefreshSession
Bsession
Caccess_token
DupdateSession
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'updateSession' is not a valid method.
Trying to access access token directly from data without session.