How to download a file in Remix? #5533
Unanswered
janhesters
asked this question in
Q&A
Replies: 2 comments
-
You can send a // routes/some[.txt].ts
export function loader() {
const content = 'some text content...';
return new Response(content, {
status: 200,
headers: {
'Content-Type': 'plain/text',
'Content-Disposition': 'attachment; filename="some.txt"',
},
});
} or add <Link to="some.txt" reloadDocument download="some.txt">some.txt file</Link> |
Beta Was this translation helpful? Give feedback.
0 replies
-
Jackardios' answer works!
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I want to allow my users to download a text file.
How would I go about this in Remix?
I tried exposing the
.txt
file via a resource route, but then the user navigates away from the page. But I'd the file to just download, or maybe have them pick a download location. In any case, I want the user to stay on the page.Beta Was this translation helpful? Give feedback.
All reactions