14. TypeScript and React
Activity 14.01: The Blog
Solution:
- Create a new React application as outlined earlier in this chapter.
- Prepare a Firestore database with authentication on Firebase as outlined in Exercise 14.04, Getting Started with Firebase.
- Install the Firebase client with
npm i firebase
. Firebase includes typings so we won't need to install those separately. - Create a directory called
services
undersrc
and a file calledfirebase.ts
there. The Firebase integration can be pretty basic:import firebase from 'firebase';const config = { apiKey: 'abc123', authDomain: 'blog-xxx.firebaseapp.com', projectId: 'https://blog-xxx.firebaseio.com', storageBucket: 'blog-xxx.appspot.com', messagingSenderId: '999', appId: '1:123:web:123abc',};firebase.initializeApp(config);export const auth = firebase.auth();export const db = firebase...