@appaflytech/wappa-auth
v0.0.5
Published
Drop-in end-user authentication for Expo / React Native and web apps, powered by the Wappa panel. Email/password + Firebase Google/Apple social login, refresh tokens, profile and password reset — one config, one hook.
Readme
@appaflytech/wappa-auth
Drop-in end-user authentication for Expo / React Native and web apps, powered by the Wappa panel. Email/password auth, refresh tokens, profile, and password reset — one config, one hook. No native dependencies; token storage is auto-detected per platform.
yarn add @appaflytech/wappa-auth
# Optional, for persistent sessions on React Native (pick one):
expo install expo-secure-store
# or
yarn add @react-native-async-storage/async-storageWeb uses
localStorageautomatically. React Native usesexpo-secure-store(preferred) or@react-native-async-storage/async-storageif installed; otherwise sessions are in-memory only.
Configuration
Pass config directly (works everywhere), or set env vars:
# Expo
EXPO_PUBLIC_WAPPA_KEY=<panel-site-key>
EXPO_PUBLIC_WAPPA_API_BASE_URL=https://wappa-ui-api.appaflytech.com
# Next.js / web
NEXT_PUBLIC_WAPPA_SITE_KEY=<panel-site-key>
NEXT_PUBLIC_WAPPA_API=https://wappa-ui-api.appaflytech.comReact usage (mobile or web)
Wrap your app once, then use the hook anywhere:
import { WappaAuthProvider, useWappaAuth } from '@appaflytech/wappa-auth'
export default function App() {
return (
<WappaAuthProvider config={{ siteKey: 'coffee' }}>
<Screens />
</WappaAuthProvider>
)
}
function LoginScreen() {
const { login, register, user, loading, isAuthenticated, logout } = useWappaAuth()
if (loading) return null
if (isAuthenticated) return <Text>Hi {user?.firstname} <Button title="Çıkış" onPress={logout} /></Text>
return (
<Button
title="Giriş"
onPress={() => login('[email protected]', 'secret').catch((e) => alert(e.message))}
/>
)
}Imperative usage (no React)
import { initWappaAuth } from '@appaflytech/wappa-auth'
const auth = await initWappaAuth({ siteKey: 'coffee' })
await auth.register({ email, password, firstname: 'Ada', lastname: 'Lovelace' })
await auth.login(email, password)
const me = await auth.me()
await auth.updateProfile({ phoneNumber: '5551112233' })
await auth.changePassword('old', 'new')
await auth.forgotPassword(email, 'https://app.example.com/reset') // emails a reset link
await auth.resetPassword(tokenFromEmail, 'newPass')
auth.getAccessToken() // attach to your own API calls
await auth.logout()API
| Method | Description |
| --- | --- |
| register(input) | Create an end-user and sign in. email + password + firstname + lastname required. |
| login(email, password) | Sign in. |
| logout() | Clear the local session. |
| me() | Fetch fresh profile. |
| updateProfile(input) | Update profile fields. |
| changePassword(old, new) | Change password. |
| forgotPassword(email, resetUrlBase?) | Email a reset link/token. Always resolves. |
| resetPassword(token, newPassword) | Complete reset; clears session. |
| getUser() / getAccessToken() / isAuthenticated() | Local accessors. |
| refresh() | Force a token refresh. |
- Authenticated calls auto-refresh the access token once on a
401. - Errors throw a
WappaAuthErrorwith.statusand.body.
Custom storage
initWappaAuth({
siteKey: 'coffee',
storage: {
getItem: async (k) => /* ... */ null,
setItem: async (k, v) => {},
removeItem: async (k) => {},
},
})Social login (Firebase Google / Apple)
Headless, like the rest of the package — it exposes methods, you design the buttons.
1. Configure in the panel
Admin UI → Kullanıcılar → Giriş Yöntemleri: toggle Google/Apple, set the Firebase Project ID,
and upload google-services.json + GoogleService-Info.plist (downloaded from the Firebase
console). The panel is the single source of truth; download them again anytime.
2. Wire the app (once)
npx wappa-auth setup # patches app.json, prints the file paths + install commands
npx expo install @react-native-firebase/app @react-native-firebase/auth \
@react-native-google-signin/google-signin expo-apple-authentication
# Download the two files from the panel → project root, then:
npx expo prebuild --clean && npx pod-install3. Use the methods
const { loginWithGoogle, loginWithApple } = useWappaAuth()
// Your own button, your own styling:
<Pressable onPress={loginWithGoogle}><Text>Google ile devam et</Text></Pressable>
<Pressable onPress={loginWithApple}><Text>Apple ile devam et</Text></Pressable>google.webClientId and which providers are enabled come from the panel at startup
(settings.authProviders) — feed webClientId into the provider config:
<WappaAuthProvider config={{ siteKey, apiUrl, google: { webClientId } }}>Already run the native flow yourself? Skip the helpers and pass the token in:
await loginWithFirebase(firebaseIdToken, 'google')Under the hood, the app sends the Firebase ID token to POST auth/sign-in-firebase; the backend
verifies it against the site's Firebase project and returns the same session as email/password.
Panel side
Manage these users from Admin UI → Kullanıcılar (list, create, ban, reset password, login history) and configure password-reset email delivery under Kullanıcılar → Mail Ayarları (SMTP).
