-
Add
formData
middleware for parsingFormData
objects from the request bodyimport { formData } from '@remix-run/fetch-router/form-data-middleware' let router = createRouter() router.use(formData()) router.map('/', ({ formData, files }) => { console.log(formData) // FormData from the request body console.log(files) // Record<string, File> from the request body return new Response('Home') })
-
Add
storage.has(key)
for checking if a value is stored for a given key -
Add
next(moreContext)
API for passing additional context to the next middleware or handler in the chain -
Move
logger
middleware to@remix-run/fetch-router/logger-middleware
export -
Add
json
andredirect
response helpersimport { json, redirect, createRouter } from '@remix-run/fetch-router' let router = createRouter() router.map('/api', () => { return json({ message: 'Hello, world!' }) }) router.map('/*path/', ({ params }) => { // Strip all trailing slashes from URL paths return redirect(`/${params.path}`, 301) })
redirect
also accepts aRoute
object for type-safe redirects:let routes = createRoutes({ home: '/', }) let response = redirect(routes.home)
Note: the route must support
GET
(orANY
) for redirects and must not have any required params, so the helper can safely construct the redirect URL.