@@ -144,6 +144,50 @@ export default function App() {
144
144
145
145
![ react-toastify] ( ./assets/sonner.gif )
146
146
147
+ ## Overriding cookie options
148
+
149
+ You can override the default cookie options by passing in your own options via the ` setToastCookieOptions ` function.
150
+
151
+ ``` tsx
152
+ import { setToastCookieOptions } from " remix-toast" ;
153
+
154
+ setToastCookieOptions ({
155
+ secrets:
156
+ process .env .NODE_ENV === " production"
157
+ ? [process .env .SESSION_SECRET ]
158
+ : [" secret" ]
159
+ });
160
+ ```
161
+
162
+ ## Creating utility functions with custom sessions
163
+
164
+ ` createToastUtilsWithCustomSession ` is a function that allows you to create a custom session for your toasts. This is useful if you want to have different types of toasts for different parts of your app.
165
+
166
+ ``` tsx
167
+ import { createCookieSessionStorage } from " @remix-run/node" ;
168
+ import { createToastUtilsWithCustomSession } from " remix-toast" ;
169
+
170
+ const session = createCookieSessionStorage ({
171
+ cookie: {
172
+ name: " your-custom-session" ,
173
+ secrets: [" some-secret" ],
174
+ },
175
+ });
176
+
177
+ export const {
178
+ useToast,
179
+ redirectWithToast,
180
+ redirectWithSuccess,
181
+ redirectWithError,
182
+ redirectWithInfo,
183
+ redirectWithWarning,
184
+ jsonWithSuccess,
185
+ jsonWithError,
186
+ jsonWithInfo,
187
+ jsonWithWarning
188
+ } = createToastUtilsWithCustomSession (session );
189
+ ```
190
+
147
191
## Utilities
148
192
149
193
### redirectWithToast
@@ -154,7 +198,7 @@ General function that allows you to redirect to a new route and show a toast mes
154
198
import { redirectWithToast } from " remix-toast" ;
155
199
156
200
export const action = () => {
157
- return redirectWithToast (" /login" , { message: " You need to login to access this page" , type: " error" });
201
+ return redirectWithToast (" /login" , { message: " You need to login to access this page" , description: " description of toast " , type: " error" });
158
202
}
159
203
160
204
```
@@ -167,7 +211,9 @@ Redirects to a new route and shows a success toast message.
167
211
import { redirectWithSuccess } from " remix-toast" ;
168
212
169
213
export const action = () => {
170
- return redirectWithSuccess (" /login" , " You are logged in!" );
214
+ return redirectWithSuccess (" /login" , " You are logged in!" );
215
+ // or with description and message (works for all the other utilities as well)
216
+ return redirectWithSuccess (" /login" , { message: " You are logged in!" , description: " description of toast" });
171
217
}
172
218
173
219
```
@@ -218,6 +264,8 @@ import { jsonWithSuccess } from "remix-toast";
218
264
219
265
export const action = () => {
220
266
return jsonWithSuccess ({ result: " Data saved successfully" }, " Operation successful! 🎉" );
267
+ // or with description and message (works for all the other utilities as well)
268
+ return jsonWithSuccess ({ result: " Data saved successfully" }, { message: " Operation successful! 🎉" , description: " description of toast" });
221
269
};
222
270
```
223
271
0 commit comments