Skip to content

Commit 4505311

Browse files
Added a note about SSR
1 parent 710db22 commit 4505311

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

README.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ In your app:
2828
4. Use the `FirebaseAuth` component in your template passing it the **Firebase UI configuration** and a **Firebase Auth instance**.
2929

3030

31-
### `FirebaseAuth` vs `StyledFirebaseAuth`
31+
### `FirebaseAuth` vs. `StyledFirebaseAuth`
3232

33-
There are two components that allow you to add FirebaseUI auth to your application: `FirebaseAuth` and `StyledFirebaseAuth`. The difference is that `FirebaseAuth` has a reference to the Firebase UI CSS (it `requires` the CSS) whereas `StyledFirebaseAuth` includes the CSS directly in its built. For simplicity you should use `StyledFirebaseAuth` and for better performances and build sizes you should use `FirebaseAuth`. `FirebaseAuth` is meant to be used with a CSS/style loader as part of yor webpack built configuration. See the [Packing your app](#packing-your-app) section
33+
There are two similar components that allow you to add FirebaseUI auth to your application: `FirebaseAuth` and `StyledFirebaseAuth`.
34+
- `FirebaseAuth` has a reference to the FirebaseUI CSS file (it `requires` the CSS).
35+
- `StyledFirebaseAuth` is bundled with the CSS directly.
36+
37+
For simplicity you should use `StyledFirebaseAuth` and for potential better performances and build sizes you can use `FirebaseAuth`. `FirebaseAuth` is meant to be used with a CSS/style loader as part of yor webpack built configuration. See the [Packing your app](#packing-your-app) section.
3438

3539

3640
### Using `StyledFirebaseAuth` with a redirect
@@ -97,6 +101,7 @@ firebase.initializeApp(config);
97101

98102
class SignInScreen extends React.Component {
99103

104+
// The component's Local state.
100105
state = {
101106
signedIn: false // Local signed-in state.
102107
};
@@ -110,13 +115,17 @@ class SignInScreen extends React.Component {
110115
firebase.auth.GoogleAuthProvider.PROVIDER_ID,
111116
firebase.auth.FacebookAuthProvider.PROVIDER_ID
112117
],
113-
// Avoid redirects after sign-in.
114-
callbacks: {signInSuccess: () => false}
118+
callbacks: {
119+
// Avoid redirects after sign-in.
120+
signInSuccess: () => false
121+
}
115122
};
116123

117124
// Listen to the Firebase Auth state and set the local state.
118125
componentWillMount() {
119-
firebase.auth().onAuthStateChanged((user) => this.setState({signedIn: !!user}));
126+
firebase.auth().onAuthStateChanged(
127+
(user) => this.setState({signedIn: !!user})
128+
);
120129
}
121130

122131
render() {
@@ -267,6 +276,13 @@ If you would like to see an example of styling, have a look at the [example app]
267276
Alternatively you can include the styling in a `<style>` tag in your application's markup.
268277

269278

279+
## Server-Side Rendering (SSR)
280+
281+
FirebaseUI React cannot be rendered on the serverside becasue the underlying, wrapped library ([FirebaseUI](https://npmjs.com/package/firebaseui) does not work server-side.
282+
283+
You may still import and include the library in an app that uses SSR: there should be no errors but no elements will be rendered.
284+
285+
270286
## Contributing
271287

272288
We'd love that you contribute to the project. Before doing so please read our [Contributor guide](CONTRIBUTING.md).

0 commit comments

Comments
 (0)