You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+76-23Lines changed: 76 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,18 +42,44 @@ modules: [
42
42
'nuxt-fire',
43
43
{
44
44
config: {
45
-
apiKey:'<apiKey>',
46
-
authDomain:'<authDomain>',
47
-
databaseURL:'<databaseURL>',
48
-
projectId:'<projectId>',
49
-
storageBucket:'<storageBucket>',
50
-
messagingSenderId:'<messagingSenderId>'
45
+
development: {
46
+
apiKey:'<apiKey>',
47
+
authDomain:'<authDomain>',
48
+
databaseURL:'<databaseURL>',
49
+
projectId:'<projectId>',
50
+
storageBucket:'<storageBucket>',
51
+
messagingSenderId:'<messagingSenderId>'
52
+
},
53
+
production: {
54
+
apiKey:'<apiKey>',
55
+
authDomain:'<authDomain>',
56
+
databaseURL:'<databaseURL>',
57
+
projectId:'<projectId>',
58
+
storageBucket:'<storageBucket>',
59
+
messagingSenderId:'<messagingSenderId>'
60
+
}
51
61
}
52
62
}
53
63
]
54
64
],
55
65
```
56
66
67
+
## Usage
68
+
69
+
You can access the various Firebase products with **\$foo** in almost any context using `app.$foo` or `this.$foo`, including store actions. Make sure to replace the _foo_ with a shortcut from the table below.
70
+
71
+
Firebase products supported by nuxt-fire so far:
72
+
73
+
| Firebase Product | Shortcut |
74
+
| ----------------- | ------------- |
75
+
| Authentication |\$fireAuth |
76
+
| Realtime Database |\$fireDb |
77
+
| Firestore |\$fireStore |
78
+
| Storage |\$fireStorage |
79
+
| Functions |\$fireFunc |
80
+
81
+
See [Firebase's official docs](https://firebase.google.com/docs/) for more usage information.
82
+
57
83
## Options
58
84
59
85
#### useOnly
@@ -64,7 +90,7 @@ By default, all supported Firebase products are loaded. If you only wish to load
Your firebase config snippet. You can retrieve this information from your Firebase project's overview page:
70
96
@@ -81,28 +107,55 @@ Your firebase config snippet. You can retrieve this information from your Fireba
81
107
}
82
108
```
83
109
84
-
Only applies when `NODE_ENV === 'production'`. In that case it is required.
110
+
`config.production` gets loaded when `NODE_ENV === 'production', same applies to 'development' and any other values that you set in NODE_ENV.
85
111
86
-
#### devConfig
112
+
#### customEnv
87
113
88
-
Same es `config`, but applies when `NODE_ENV === 'development'`. In that case it is required
114
+
By default, the Firebase config will be chosen based on the NODE_ENV environment variable.
89
115
90
-
## Usage
116
+
If customEnv is set to true, however, nuxt-fire will determine the environment based on the environment variable called FIRE_ENV, which you can define yourself. This gives you the flexibility to define as many different Firebase configs as you like, independent of your NODE_ENV.
91
117
92
-
You can access the various Firebase products with **\$foo** in almost any context using `app.$foo` or `this.$foo`, including store actions. Make sure to replace the _foo_ with a shortcut from the table below.
118
+
- type: `Boolean`
119
+
- default: `false`
120
+
- required: `false`
93
121
94
-
Firebase products supported by nuxt-fire so far:
122
+
_⚠️ Important:_
95
123
96
-
| Firebase Product | Shortcut |
97
-
| ----------------- | ------------- |
98
-
| Authentication |\$fireAuth |
99
-
| Realtime Database |\$fireDb |
100
-
| Firestore |\$fireStore |
101
-
| Storage |\$fireStorage |
102
-
| Functions |\$fireFunc |
124
+
If you decide to turn on this option, you need to add the following code to your `nuxt.config.js` to make sure that the environment variable gets passed from server to client.
103
125
104
-
See [Firebase's official docs](https://firebase.google.com/docs/) for more usage information.
126
+
```js
127
+
env: {
128
+
FIRE_ENV:process.env.FIRE_ENV
129
+
}
130
+
```
131
+
132
+
After that, you can set FIRE_ENV to anything you like...
133
+
134
+
```js
135
+
"scripts": {
136
+
"serveFoo":"FIRE_ENV=foofoofoo nuxt",
137
+
"serveFaa":"FIRE_ENV=faafaafaa nuxt",
138
+
}
139
+
```
140
+
141
+
And then add your config to the nuxt-fire options in your `nuxt.config.js`:
142
+
143
+
```js
144
+
config: {
145
+
foofoofoo: {
146
+
apiKey:'<apiKey>',
147
+
authDomain:'<authDomain>',
148
+
databaseURL:'<databaseURL>',
149
+
projectId:'<projectId>',
150
+
storageBucket:'<storageBucket>',
151
+
messagingSenderId:'<messagingSenderId>'
152
+
},
153
+
faafaafaa: {
154
+
//
155
+
}
156
+
}
157
+
```
105
158
106
-
###Examples
159
+
## Examples
107
160
108
-
Check out the [GitHub Repo](https://github.com/lupas/nuxt-fire-demo) of our [Demo](https://nuxt-fire-demo.firebaseapp.com/) for example code.
161
+
Check out our [Demo](https://nuxt-fire-demo.firebaseapp.com/) or its [GitHub Repo](https://github.com/lupas/nuxt-fire-demo) for example code.
0 commit comments