Replies: 3 comments 6 replies
-
hey there! so…cookie based auth probably won’t work here, since cookies are a web-only concept. at least, that’s my understanding. there is an open discussion about auth at #39 i use firebase auth on both web and native and it works great. it’s JWT-based. i want to add a solito example, but it’s a good amount of work out of the many requests I get, so I haven’t had time to quite yet. the easiest thing may be would be to use firebase JS. depends what auth providers you’d want I think. i use firebase JS on web and react-native-firebase on iOS/android for optimal native performance. without a good starter template, this might be a bit more setup for a beginner. clearly auth is a big need for an example / documentation, and hopefully when i free up some time from work i can make an example with what we do. |
Beta Was this translation helpful? Give feedback.
-
So I am going to give firebase a try! I have been following rnfirebase.io (toward the end of getting started where they talk about expo) and I ran into an error
And fixed it with adding use_modular_headers! to the pod file Expo now runs but when I run the app I get the following errors
I understand if you want to wait until you release an example first before helping people with this, but I can't seem to find anything online to help with this error. Any pointers on how you did it would be appreciated! Im assuming you added "@react-native-firebase/app": "^15.1.1" to the package.json in the expo folder and then ran expo prebuild --clean. I'll be willing to write up a complete guide if I ever get it working lol :) |
Beta Was this translation helpful? Give feedback.
-
Setting Up Firebase and expo-auth-session with Solito(Please comment on problems you find or any suggestions!) First, install Solito with
Now install FireBase and expo-auth-session. (I believe expo-auth-session can be used for google logins with firebase but I haven't confirmed this, I will do soon)
Also, you will need to update react-native-reanimated to version 2.8.0. then run
Note: upgrading to 2.9.0 breaks nextjs Edit your app.json file to include the following, Also now would be a good time to set up your Firebase Project and add an ios and android app to your Firebase project to get the following files: GoogleService-Info.plist, google-services.json. These files need to be added to the root directory of /expo before you continue. Note "com.my-solito-app" need to match what you entered on the Firebase website. "ios": {
"bundleIdentifier": "com.my-solito-app",
"googleServicesFile": "./GoogleService-Info.plist"
},
"android": {
"package": "com.my-solito-app",
"googleServicesFile": "./google-services.json"
},
"plugins": [
"@react-native-firebase/app",
"@react-native-firebase/perf",
"@react-native-firebase/crashlytics"
] Now let us run the following command, this will fail because ios pods aren't set up correctly, but it will do a lot of the work for us in terms of setting up firebase in ios and android
Now to set up the podfile correctly with the following lines
After that, you can clean and install pods
Now we can build the ios or android
It should be installed now, to test this add the following into a firebase.tsx file, this will be accompanied by a firebase.web.tsx file later. import auth from '@react-native-firebase/auth'
export function createUser() {
auth()
.createUserWithEmailAndPassword(
'[email protected]',
'SuperSecretPassword!'
)
.then(() => {
console.log('User account created & signed in!')
})
.catch((error) => {
if (error.code === 'auth/email-already-in-use') {
console.log('That email address is already in use!')
}
if (error.code === 'auth/invalid-email') {
console.log('That email address is invalid!')
}
console.error(error)
})
} And add the following to any screen to test! import { createUser } from 'app/provider/FirebaseAuth/firebase'
//later in file
<MotiPressable onPress={createUser}>
<Text> Click to create Account</Text>
</MotiPressable> You should see a console.log of 'User account created & signed in!' if it's your first time. Note you need to setup username-and-password signup on the firebase website under authentication -> Sign-in Methods Setup NextjsGo into /apps/next and run
to test if this is working add the following into _app.tsx. The firebaseConfig info comes from the firebase website import { initializeApp } from 'firebase/app'
const firebaseConfig = {
apiKey: '',
authDomain: '',
projectId: '',
storageBucket: '',
messagingSenderId: '',
appId: '',
measurementId: '',
}
// Initialize Firebase
const app = initializeApp(firebaseConfig) And then add the following into the file firebase.web.tsx import { getAuth, createUserWithEmailAndPassword } from 'firebase/auth'
export function createUser() {
const auth = getAuth()
createUserWithEmailAndPassword(
auth,
'[email protected]',
'SuperSecretPassword!'
)
.then(() => {
console.log('User account created & signed in!')
})
.catch((error) => {
if (error.code === 'auth/email-already-in-use') {
console.log('That email address is already in use!')
}
if (error.code === 'auth/invalid-email') {
console.log('That email address is invalid!')
}
console.error(error)
})
} When calling this function you should get an error saying this email is already in use! I believe this covers everything that you would need to use Firebase Auth with Solito! |
Beta Was this translation helpful? Give feedback.
-
Hello people!
So I'm new to React, NextJS, React Native, and now Solito. Last month I learned how to make a website in NextJS with authentication, profiles, posts, upvotes, etc. I am now trying to learn app development and came across this project but there isn't much in terms of tutorials or guides.
I am wanting to know what is a recommended way to do Authentication with Solito that would work well with both React Native and NextJS. I used Cookies with my first website project, and found this might be an option, react-native-cookies, but am looking for opinions and suggestions on what would work, and how to get it to work. (i.e do they need to be done separately or can they be done together within solito)
Beta Was this translation helpful? Give feedback.
All reactions