S
Supabase2mo ago
gov

Supabase branch API URL/anon key for expo preview build

Hi all, I'm trying to set up a CI/CD flow that coordinates github branches, supabase branch, expo preview build. I have Supabase creating new branches with Github on new PR creation, and I have Expo creating a preview build for that branch, however I'm not able to set the right API URL/anon key as I don't know what it's going to be when it's generated. Is there any way to fetch that information? Is this the right way of approaching this? Ideally, a reviewer would be able to scan the QR code in the PR and test features on the preview branch of the database without affecting any staging/prod data.
3 Replies
ihm40
ihm402mo ago
What is the setup that you have, is it a mono repo? because the supabase branch is created once and will remain with the same anon key and url i would probably create the branch first in supabase and then set the environment variables in expo this is probably how i would approach it since you would only have to set it once per branch. I can't find anything that suggests automatic environment variables being passed into expo.
gov
govOP2mo ago
Yup it's a monorepo. I didn't mean automatic env vars being passed, more so if I'm able to fetch the api URL/anon key from the newly created branch
ihm40
ihm402mo ago
the way you can get those values is from the branch in supabase i believe? if you switch the branch value on the dashboard then you should be able to go into the settings for keys and get the anon key and the url of that branch will provide the project url A branch can be thought of like a supabase project in it's own right so fetching any details about it should be the same as fetching it from your normal project

Did you find this page helpful?