SSR for One Page? #1739
Unanswered
threehappypenguins
asked this question in
Help & Questions
Replies: 1 comment
-
It's a bit difficult to help: you write a lot of things that may or may not be related to your issue. A better approach would be to describe what you expect from Vike and what happens instead. (FYI adding guides for newcomers to frontend development is on our radar.) |
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
-
TL;DR I am looking for help on how to make my Connect.jsx page SSR. When I refresh the page, the button "flickers" to show
Connect to YouTube
and quickly changes toDisconnect YouTube
(when my account is connected). I figured SSR would solve this problem.I built a MERN stack. I am trying to implement SSR for just one page using Vike. I am very new to development in general, so my brain feels like scrambled eggs right now. I apologize if the answers to my questions are very obvious. Here is the current structure of my project:
Here is my vite.config.mjs:
Note that I don't have
plugins: [react(), vike()],
andimport vike from 'vike/plugin'
is commented out. The reason that I have done that for now is because as soon as I add thevike()
plugin, then all my pages becomeCannot GET
. That is expected, since I would have to set up Filesystem Routing for each page. I'm a little lost on how to just get one page (Connect.jsx
) set up for SSR, but not the rest of the pages.For example, say I change the structure to:
And for clarification, here is my
Connect.jsx
page (orconnect/+Page.jsx
):I can access the page from localhost:3000/connect but I can't access any of my other pages, can't access the navbar, nothing. I tried reading through the documentation for adding SSR to an existing app, but I'm lost. For example, I tried adjusting server.js in my backend to server.mjs, and implementing some way to add a test route while leaving the rest of my routes alone and implementing
renderPage
(). Here is my original server.js (in the backend):And here is server.mjs with my test route:
When I try a GET request in Postman with
localhost:4000/test
, I get 404 not found. I mean, I figured it wouldn't be found, but I don't really understand what to do. I know I'm not thinking about things correctly. I just don't know how to think about it (if that makes sense).Can I have some guidance on how to go about this, or if what I'm trying to do is even possible?
Beta Was this translation helpful? Give feedback.
All reactions