Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Single Page Application #4088

Closed
kaym0 opened this issue Mar 31, 2018 · 12 comments
Closed

Question: Single Page Application #4088

kaym0 opened this issue Mar 31, 2018 · 12 comments

Comments

@kaym0
Copy link

kaym0 commented Mar 31, 2018

I'm relatively new to using next.js [and React] and I had a question I thought would be best asked here. Is it possible to build a single page application with next.js? I can't seem to figure out how to have a static navbar/menu that won't reload when routing. Do I need to implement custom routing to make this possible? Are there any examples of someone who has already done this? I tried next-layouts and I really don't think it did anything I could not have done without it. Maybe I didn't use it right, though.

Thanks. Also, I have read the examples and previous issues regarding Semantic-UI and was wondering if anyone has figured out how to locally load it without using a stylesheet CDN. Even with the loaders setup properly and no errors showing, it clearly does not load and my page just looks pretty vanilla. :P

@guiihlopes
Copy link

guiihlopes commented Mar 31, 2018

Yes, it's possible to build a SPA with next.js, you need to use Link component as mentioned here: Link or use this example to do it programmatically: Link with Router

About Semantic UI, you can use this example: Semantic UI without CDN

Hope it helps ;)

@timneutkens
Copy link
Member

For the layout that doesn't reload see #88 (will come soon).

If by SPA you mean running next without a node server, that's currently only possible using next export which produces static html for pages.

next/link does client side routing.

@kaym0
Copy link
Author

kaym0 commented Mar 31, 2018

No I just meant a Single Page Application which runs server side, with the basic layout (like the navigation) not reloading, only the content. I previously was using Vue before switching to React and was building SPA on that.

Basically, you would build a layout was inside of app.js and then any of the content would load inside of that in the content area. Mostly I just like it for the navigation bar so that it doesn't have to reload every time you switch pages. It just looks more fluid. This, I think, required Vue-Router.

Thanks for the replies guys. Looking forward to getting to know more about Next.js

@timneutkens
Copy link
Member

For the layout that doesn't reload see #88 (will come soon).

@kaym0
Copy link
Author

kaym0 commented Mar 31, 2018

Yes, I'm checking that out just wanted to clarify that I did not want to run a static html page without a server.

@kaym0
Copy link
Author

kaym0 commented Mar 31, 2018

So to clarify: this will not be available until Next 6.x?

@timneutkens
Copy link
Member

Indeed 🔜

@hi-rad
Copy link

hi-rad commented May 19, 2018

@timneutkens I am working with Next 6.0.2 and it still reloads the layout. I want to user redux to fetch the menu however the layout is being re-rendered every time and getInitialProps of _app.js is also being called on every request. Shouldn't getInitialProps of _app.js be called once? (And also the re-rendering of the layout is an issue, isn't it?)

@AleVul
Copy link

AleVul commented Aug 6, 2018

I have the same problem, _app.jsx getInitialProps is called every time when i navigate to a page that changes its content through query string. I do use routing apis to set the query, but that should only afect pages's getInitialProps not the _app's.
next.js version is 6.1.1.

@ghost
Copy link

ghost commented Oct 14, 2018

Is there any update with this issue? I am using v7, but it seems that layouts rerendering still exists. Any solution?

@ghost
Copy link

ghost commented Oct 25, 2018

I haven't tried it yet, but seems that custom app override solves the problem.

@tky5622
Copy link

tky5622 commented Oct 31, 2018

what does the custom app override mean ?
I'm also have the problem with making layout component and setting it in _app.js.
I really want solution for dynamic menu.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants