search

Home  >  Q&A  >  body text

Routing from page 1 to page 2 and then using the browser to go back to page 1 breaks page 1

I'm using typescript routing based on next 13.4.5 and /app.

In my page 1 I have (next/link) from which I can navigate to page 2. If I use the browser back button to go back to page 1, the entire page breaks. For example, the top section disappears and the page starts in the middle. The rest of the page's CSS doesn't work, etc.

My page 1 is completely SSR. But in page 2, I used "use client"; in page.tsx.

Share the deployment version of the above site:

  1. The homepage is page 1.
  2. The login page is page 2.

To copy, visit https://buzzli.vercel.app and press the "Start" button in the upper right corner. This is the next/link tag. It will take you to the login page. Then try to use the back button to go back to the previous page. You will see errors.

I don't know what I'm doing wrong here, so not sharing any code.

P粉033429162P粉033429162467 days ago496

reply all(1)I'll reply

  • P粉022285768

    P粉0222857682023-09-15 12:15:47

    I found the problem.

    Actually the problem is with the nested tags.

    The project structure is like this:

    /
    --> layout
    --> page
    --> /login
        --> layout (the problem lied here)
        --> page

    I mistakenly placed another html tag inside this internal layout file.

    reply
    0
  • Cancelreply