@@ -144,6 +144,50 @@ export default function App() {
144144
145145![ react-toastify] ( ./assets/sonner.gif )
146146
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+
147191## Utilities
148192
149193### redirectWithToast
@@ -154,7 +198,7 @@ General function that allows you to redirect to a new route and show a toast mes
154198import { redirectWithToast } from " remix-toast" ;
155199
156200export 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" });
158202}
159203
160204```
@@ -167,7 +211,9 @@ Redirects to a new route and shows a success toast message.
167211import { redirectWithSuccess } from " remix-toast" ;
168212
169213export 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" });
171217}
172218
173219```
@@ -218,6 +264,8 @@ import { jsonWithSuccess } from "remix-toast";
218264
219265export const action = () => {
220266 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" });
221269};
222270```
223271
0 commit comments