Can FormStrategy be updated to support context from react router v7? #66
Replies: 2 comments
-
|
Hi @dtrikannad, Currently, FormStrategy only provides access to the form and request objects, and it does not automatically expose the React Router context. If you need access to your Cloudflare D1 database context, you have a few options: 1 - Inject context manually: Attach the DB connection to the request object before calling the strategy. 2 - Wrapper function: Create a wrapper around your strategy to provide the context explicitly. 3 - Custom strategy extension: Extend FormStrategy and override the parts where the context is required, injecting your DB connection there. Please note that support for React Router v7 in some authentication strategies might be limited, so you may need minor adjustments. I hope this helps! If this solves your issue, I’d appreciate it if you could mark this as the accepted answer. |
Beta Was this translation helpful? Give feedback.
-
|
You can import If you already set the Drizzle client in the router context, you can use AsyncLocalStorage to access it in Remix Auth strategies, there's a middleware in Remix Utils to do this https://github.com/sergiodxa/remix-utils#context-storage-middleware |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to access the DB Connection from within the FormStrategy, but it only provides access to form and request objects. Or is there another way to access context from within this strategy? I need this to access the DB which is being stored wtihint he context for Cloudflare's D1 DB.
Beta Was this translation helpful? Give feedback.
All reactions