Next.js Discord

Discord Forum

Why does `next build` create .txt files?

Answered
Hilsa shad posted this in #help-forum
Open in Discord
Hilsa shadOP
I am running 13.5.4, my config file has output: export, the site itself is all static rendered, all pages use app router.

I run next build and alongside every html file, there is a text file with the same path. I have deleted those .txt files and nothing seems to break.

The problem this causes is that the site is running on Cloudflare pages which has 20k page limit, and the .txt files obviously half that limit because every route has two files. Obviously, I can just delete the .txt files every time but I would like to know if the site is breaking in some way I haven't been able to find (and the reason why this happens because I am curious and couldn't find any info in the docs).
Answered by riský
the txt is for rsc payloads (so that it can get the page data but not need to actually get the html document)
View full answer

21 Replies

the txt is for rsc payloads (so that it can get the page data but not need to actually get the html document)
Answer
Hilsa shadOP
So it is only used for hydration? And removing the .txt files would only break the site if you had Client Components?
next/link does page render without using the next html file, but then to get the new page's data, it needs to use txt
Hilsa shadOP
So links should be broken?
if you remove the txt's, yes
if you keep, it should work
Hilsa shadOP
Ah, I see now...
I checked the console and it is throwing 404 when I follow links for the missing .txt
The pages look fine but it is looking for .txt
sounds about right
also, why do you have 10k pages anyway? dynamic routes (and lots of options)
Hilsa shadOP
Because the pages don't change often and I don't want to run server
I also prefer the web pages to be split away from db, I need db running on my own network but this is a problem if you want to build on cloud provider
@riský next/link does page render without using the next html file, but then to get the new page's data, it needs to use txt
Hilsa shadOP
Is this for the "pre-render" on the client where next looks at links on a page and loads data for them before you click?
yeah, it downloads those files, and then when you click the link, instant page change
Hilsa shadOP
👍 Got it now
Will need to do some more reading but I appreciate your time and experience.
yeah, this is kinda hard to explain...
Hilsa shadOP
It is clear. I was aware of some of this but there is no explanation of the text files in the docs...I should have just checked the console and then I would have understood.
Ty.
tbf that is only how i understood it