Table of Contents
- set
- setWithMeta
- push
- pushWithMeta
- update
- updateWithMeta
- remove
- uniqueSet
- uploadFile
- uploadFiles
- deleteFile
- watchEvent
- unWatchEvent
- promiseEvents
- login
- logout
- createUser
- resetPassword
- confirmPasswordReset
- verifyPasswordResetCode
- updateProfile
- updateAuth
- updateEmail
- reloadAuth
- linkWithCredential
- signInWithPhoneNumber
- ref
- database
- storage
- auth
set
Sets data to Firebase.
Parameters
path
String Path to location on Firebase which to setvalue
(Object | String | Boolean | Number) Value to write to FirebaseonComplete
Function Function to run on complete (not required
)
Examples
Basic
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { firebaseConnect } from 'react-redux-firebase'
const Example = ({ firebase: { set } }) => (
<button onClick={() => set('some/path', { here: 'is a value' })}>
Set To Firebase
</button>
)
export default firebaseConnect()(Example)
Returns Promise Containing reference snapshot
setWithMeta
Sets data to Firebase along with meta data. Currently, this includes createdAt and createdBy. Warning using this function may have unintented consequences (setting createdAt even if data already exists)
Parameters
path
String Path to location on Firebase which to setvalue
(Object | String | Boolean | Number) Value to write to FirebaseonComplete
Function Function to run on complete (not required
)
Returns Promise Containing reference snapshot
push
Pushes data to Firebase.
Parameters
path
String Path to location on Firebase which to pushvalue
(Object | String | Boolean | Number) Value to push to FirebaseonComplete
Function Function to run on complete (not required
)
Examples
Basic
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { firebaseConnect } from 'react-redux-firebase'
const Example = ({ firebase: { push } }) => (
<button onClick={() => push('some/path', true)}>
Push To Firebase
</button>
)
export default firebaseConnect()(Example)
Returns Promise Containing reference snapshot
pushWithMeta
Pushes data to Firebase along with meta data. Currently, this includes createdAt and createdBy.
Parameters
path
String Path to location on Firebase which to setvalue
(Object | String | Boolean | Number) Value to write to FirebaseonComplete
Function Function to run on complete (not required
)
Returns Promise Containing reference snapshot
update
Updates data on Firebase and sends new data.
Parameters
path
String Path to location on Firebase which to updatevalue
(Object | String | Boolean | Number) Value to update to FirebaseonComplete
Function Function to run on complete (not required
)
Examples
Basic
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { firebaseConnect } from 'react-redux-firebase'
const Example = ({ firebase: { update } }) => (
<button onClick={() => update('some/path', { here: 'is a value' })}>
Update To Firebase
</button>
)
export default firebaseConnect()(Example)
Returns Promise Containing reference snapshot
updateWithMeta
Updates data on Firebase along with meta. Warning using this function may have unintented consequences (setting createdAt even if data already exists)
Parameters
path
String Path to location on Firebase which to updatevalue
(Object | String | Boolean | Number) Value to update to FirebaseonComplete
Function Function to run on complete (not required
)
Returns Promise Containing reference snapshot
remove
Removes data from Firebase at a given path. NOTE A
seperate action is not dispatched unless dispatchRemoveAction: true
is
provided to config on store creation. That means that a listener must
be attached in order for state to be updated when calling remove.
Parameters
path
String Path to location on Firebase which to removeonComplete
Function Function to run on complete (not required
)options
Examples
Basic
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { firebaseConnect } from 'react-redux-firebase'
const Example = ({ firebase: { remove } }) => (
<button onClick={() => remove('some/path')}>
Remove From Firebase
</button>
)
export default firebaseConnect()(Example)
Returns Promise Containing reference snapshot
uniqueSet
Sets data to Firebase only if the path does not already exist, otherwise it rejects. Internally uses a Firebase transaction to prevent a race condition between seperate clients calling uniqueSet.
Parameters
path
String Path to location on Firebase which to setvalue
(Object | String | Boolean | Number) Value to write to FirebaseonComplete
Function Function to run on complete (not required
)
Examples
Basic
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { firebaseConnect } from 'react-redux-firebase'
const Example = ({ firebase: { uniqueSet } }) => (
<button onClick={() => uniqueSet('some/unique/path', true)}>
Unique Set To Firebase
</button>
)
export default firebaseConnect()(Example)
Returns Promise Containing reference snapshot
uploadFile
Upload a file to Firebase Storage with the option to store its metadata in Firebase Database
Parameters
path
String Path to location on Firebase which to setfile
File File object to upload (usually first element from array output of select-file or a drag/droponDrop
)dbPath
String Database path to place uploaded file metadataoptions
Object Optionsoptions.name
String Name of the file
Returns Promise Containing the File object
uploadFiles
Upload multiple files to Firebase Storage with the option to store their metadata in Firebase Database
Parameters
path
String Path to location on Firebase which to setfiles
Array Array of File objects to upload (usually from a select-file or a drag/droponDrop
)dbPath
String Database path to place uploaded files metadata.options
Object Optionsoptions.name
String Name of the file
Returns Promise Containing an array of File objects
deleteFile
Delete a file from Firebase Storage with the option to remove its metadata in Firebase Database
Parameters
path
String Path to location on Firebase which to setdbPath
String Database path to place uploaded file metadata
Returns Promise Containing the File object
watchEvent
Watch event. Note: this method is used internally so examples have not yet been created, and it may not work as expected.
Parameters
type
String Type of watch eventpath
String Path to location on Firebase which to set listenerstoreAs
String Name of listener results within redux storeoptions
Object Event options object (optional, default{}
)
Returns Promise
unWatchEvent
Unset a listener watch event. Note: this method is used internally so examples have not yet been created, and it may not work as expected.
Parameters
type
String Type of watch eventpath
String Path to location on Firebase which to unset listenerqueryId
String Id of the listeneroptions
Object Event options object (optional, default{}
)
Returns Promise
promiseEvents
Similar to the firebaseConnect Higher Order Component but
presented as a function (not a React Component). Useful for populating
your redux state without React, e.g., for server side rendering. Only
once
type should be used as other query types such as value
do not
return a Promise.
Parameters
watchArray
Array Array of objects or strings for paths to sync from Firebase. Can also be a function that returns the array. The function is passed the props object specified as the next parameter.options
Object The options object that you would like to pass to your watchArray generating function.
Returns Promise
login
Logs user into Firebase. For examples, visit the auth section
Parameters
credentials
Object Credentials for authenticatingcredentials.provider
String External provider (google | facebook | twitter)credentials.type
String Type of external authentication (popup | redirect) (only used with provider)credentials.email
String Credentials for authenticatingcredentials.password
String Credentials for authenticating (only used with email)
Returns Promise Containing user's auth data
logout
Logs user out of Firebase and empties firebase state from redux store
Returns Promise
createUser
Creates a new user in Firebase authentication. If
userProfile
config option is set, user profiles will be set to this
location.
Parameters
credentials
Object Credentials for authenticatingprofile
Object Data to include within new user profile
Returns Promise Containing user's auth data
resetPassword
Sends password reset email
Parameters
credentials
Object Credentials for authenticatingcredentials.email
String Credentials for authenticating
Returns Promise
confirmPasswordReset
Confirm that a user's password has been reset
Parameters
Returns Promise
verifyPasswordResetCode
Verify that a password reset code from a password reset email is valid
Parameters
code
String Password reset code to verify
Returns Promise Containing user auth info
updateProfile
Update user profile
Parameters
profileUpdate
profile
Object Profile data to place in new profile
Returns Promise
updateAuth
Update Auth Object
Parameters
Returns Promise
updateEmail
Update user's email
Parameters
Returns Promise
reloadAuth
Reload user's auth object. Must be authenticated.
Returns Promise
linkWithCredential
Links the user account with the given credentials.
Parameters
credential
firebase.auth.AuthCredential The auth credential
Returns Promise
signInWithPhoneNumber
Asynchronously signs in using a phone number. This method
sends a code via SMS to the given phone number, and returns a modified
firebase.auth.ConfirmationResult. The confirm
method
authenticates and does profile handling.
Parameters
credential
firebase.auth.ConfirmationResult The auth credential
Returns Promise
ref
Firebase ref function
Returns firebase.database.Reference
database
Firebase database service instance including all Firebase storage methods
Returns firebase.database.Database Firebase database service
storage
Firebase storage service instance including all Firebase storage methods
Returns firebase.database.Storage Firebase storage service
auth
Firebase auth service instance including all Firebase auth methods
Returns firebase.database.Auth