How to call a 'server' function w/o a form? #1321
Unanswered
aloukissas
asked this question in
Q&A
Replies: 1 comment 3 replies
-
You can create a resource route (https://remix.run/docs/en/v1/guides/resource-routes#creating-resource-routes) and call it with fetch. This would be the 1:1 mapping from Next's API routes. Basically, to create an "API route", in a new file export a loader and/or an action, without a default component export. That route will be treated as a resource route. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Many use cases here, but I'll give an example of what I'm trying to prototype. I'm integrating the plaid link library and I need to call a server function in a callback (see example project in plain reactjs here). In e.g. NextJS, this would translate in an "API route" call. I may have missed it in Remix's docs, but it looks the only way to trigger server functions is with submitting a form.
Beta Was this translation helpful? Give feedback.
All reactions