Can I use t3 for single page apps?

I've heard next js isnt great for spas, so im wondering if its doable with t3 or if i should pick a different framework. thanks
28 Replies
cje
cje13mo ago
SPAs is the only thing Next can make
deforestor
deforestor13mo ago
I would be lying if I said that didn't confuse the hell out of me I have a guess on what I think you mean, but can you elaborate?
cje
cje13mo ago
SPA means the server sends one html page (Single Page) and then JavaScript takes over That’s how Next works
deforestor
deforestor13mo ago
Ah yeah, if that's the definition of SPA, that makes sense
brunoeduardodev
brunoeduardodev13mo ago
the only difference IMO is a SPA application, using Vite, for example, is easier and cheaper to deploy than nextjs but if it's not a concern, I don't thnk there's a reason for not using next you can actually also statically export your nextjs app, so I'm actually talking shit rn
cloutw
cloutw13mo ago
every nextjs site ive seen is multi page also it makes a pages folder on init, what is that for?
brunoeduardodev
brunoeduardodev13mo ago
having different different routes, as entrypoints the app you want to build has only a single route?
cloutw
cloutw13mo ago
im not 100% on what routing is, but basically its just one page and has a bunch of toggleable modules, almost like a dashboard type thing
brunoeduardodev
brunoeduardodev13mo ago
ah, I see, alright, so just to prevent some confusion, when the term "SPA" is used, it's usually talking about applications that have only one page, or "only one html file", not that it's a page with only one router, "or only one url"
deforestor
deforestor13mo ago
That's the confusion I had, but essentially, having multiple pages doesn't mean it'll load multiple pages. According to cje, what Next does is send only one page, always That's a very technical and slightly ambiguous definition
cloutw
cloutw13mo ago
sorry, im still a bit confused, if it has multiple pages, how is it not going to load multiple pages?
deforestor
deforestor13mo ago
yeah, I totally thought SPA was more of a design term lol
brunoeduardodev
brunoeduardodev13mo ago
there's some ways of handling multiple pages / multiple URLs, in your application, the traditional way is each page is hosted ("stored") in a different file on the server, and every time you reach this URL you are grabbing this file from the server
deforestor
deforestor13mo ago
My dumb explanation would be: when you click on a link to go to another page (another route), Next will send only that page to you and the page that you had before will "be replaced" by the new one
cloutw
cloutw13mo ago
is that not an mpa?
deforestor
deforestor13mo ago
No, because you are still only using one page You're only rendering different stuff in that page
brunoeduardodev
brunoeduardodev13mo ago
the way nextjs works is, the first time you reach a page, it's going to send the full content of that page, for example all the libraries, stylings, etc, But when you go to the second page, only the content that is different is going to be send to you
cloutw
cloutw13mo ago
ah ok thats a great explanation also thanks for the video
whatplan
whatplan13mo ago
think of an spa like a desktop app, all of the logic and ui for the entire thing is loaded once (nextjs doesnt work exactly like this but good way to think) and 'routing' simply changes the internal state of the 'app'
cje
cje13mo ago
Also just open the network tab (on a built site, not in dev) and see what it sends you on initial load, clicking a link, etc
whatplan
whatplan13mo ago
where an mpa is a completely fresh brand new page and everything on navigation
cje
cje13mo ago
This isn’t necessarily true, you can bundle split, lazy load, etc in an SPA (and almost of the good ones do)
whatplan
whatplan13mo ago
was already editing was trying to simply for the purpose of understanding imagine a CRA with zero bundling idk if you know what that it
cloutw
cloutw13mo ago
create react app?
whatplan
whatplan13mo ago
yea so cra is the classic 'spa'
cloutw
cloutw13mo ago
ok ok that makes more sense thanks for the help guys
brunoeduardodev
brunoeduardodev13mo ago
but answering your initial question clout, yes, you can use t3 just use what you think it's cool if you like watching t3 videos or like the content it's enough you're more likely going to reach some barriers if you use a SPA like CRA or Vite than using nextjs from the beginning imo