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

Migrated project from pages to app router #380

Open
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

zoosphar
Copy link
Contributor

Objective
This PR will migrate the jsoncrack project from the old next.js pages router to the new app router.

Changes

  1. Project structure to consider the app directory as the entry point and move all the existing routes from the pages directory.
  2. pages/_app.tsx and pages/_document.tsx files are replaced by app/layout.tsx.
  3. Custom metatags inside the headtags are replaced by exporting the metadata constant from the app/layout.tsx file. I will continue doing the same for all files.
  4. pages/_error.tsx is replaced by app/not-found.tsx which can not only serve a custom error UI but can also send HTTP status and serve metatags out of the box.
  5. next/router is replaced by next/navigation which is a simplified API.

References used for migration

  1. https://nextjs.org/docs
  2. https://nextjs.org/docs/pages/building-your-application/upgrading/app-router-migration#migrating-from-pages-to-app

Testing
Tested the routes and functionalities by doing feature by feature test taking the production(jsoncrack.com) as the reference.

Copy link
Contributor

@TallTed TallTed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Language improvements

icon: "/favicon.ico",
},
description:
"Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML, CSV and more, into interactive graphs.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML, CSV and more, into interactive graphs.",
"Innovative and open-source visualization application that produces interactive graphs from various data formats, such as JSON, YAML, XML, CSV and more.",

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TallTed Thank you for suggesting these changes but I didn't change any language in the metatags, it was as it is from the original repo.
This PR only focuses on upgrading the project from the pages router to the app router.

Will fix these in another PR maybe.

description:
"Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML, CSV and more, into interactive graphs.",
openGraph: {
title: "JSON Crack - Visualize Data to Graphs",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
title: "JSON Crack - Visualize Data to Graphs",
title: "JSON Crack - Visualize Data as Graphs",

Comment on lines 25 to 28
title: "JSON Crack - Visualize Data to Graphs",
description:
"Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML, CSV and more, into interactive graphs.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
title: "JSON Crack - Visualize Data to Graphs",
description:
"Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML, CSV and more, into interactive graphs.",
title: "JSON Crack - Visualize Data as Graphs",
description:
"Innovative and open-source visualization application that produces interactive graphs from various data formats, such as JSON, YAML, XML, CSV and more.",

@TallTed
Copy link
Contributor

TallTed commented Jan 24, 2024

I'm not sure what you would like me to review. My previously suggested changes appear not to have been applied, though at least some of the text I suggested to change has been edited differently, but these edits are only visible commit-by-commit, not in the "files changed"...

@zoosphar
Copy link
Contributor Author

zoosphar commented Jan 27, 2024

I'm not sure what you would like me to review. My previously suggested changes appear not to have been applied, though at least some of the text I suggested to change has been edited differently, but these edits are only visible commit-by-commit, not in the "files changed"...

Hey @TallTed the changes you suggested are not in the scope of this PR, this PR only focuses on migrating the project from the pages router to the app router. Hence, I migrated the metadata from independent tags to a default object export.
Can you please review the migration and the adoption of new hooks like 'next/navigation' for routing?

@zoosphar
Copy link
Contributor Author

Hey @TallTed
I have updated the metadata in this PR only. Please have a look at this commit

@zoosphar zoosphar marked this pull request as ready for review January 28, 2024 11:18
src/app/layout.tsx Outdated Show resolved Hide resolved
Co-authored-by: Ted Thibodeau Jr <tthibodeau@openlinksw.com>
@zoosphar zoosphar requested a review from TallTed February 1, 2024 10:42
Copy link
Contributor

@TallTed TallTed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm fwiw (I code almost exclusively in English)

@AykutSarac
Copy link
Owner

Looks like no migration made for useSearchParams, can we do that? Also why did we add the "impl" package to the project?

@@ -36,14 +36,14 @@ const StyledHighlight = styled.span<{ $link?: boolean; $alert?: boolean }>`
margin: ${({ $alert }) => ($alert ? "8px 0" : "1px")};
`;

const Docs = () => {
export default function Page() {
return (
<Layout>
<Head>
<title>Documentation - JSON Crack</title>
<meta name="description" content="Embedding JSON Crack tutorial into your websites." />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<meta name="description" content="Embedding JSON Crack tutorial into your websites." />
<meta name="description" content="Embedding JSON Crack tutorial in your websites." />

Comment on lines 21 to 22
Page you are trying to open does not exist. You may have mistyped the address, or the page
has been moved to another URL. If you think this is an error contact support.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Page you are trying to open does not exist. You may have mistyped the address, or the page
has been moved to another URL. If you think this is an error contact support.
The page you are trying to open does not exist. You may have mistyped the address, or the page
may have been moved to another URL. If you think this is an error, contact support.

@zoosphar
Copy link
Contributor Author

Looks like no migration made for useSearchParams, can we do that? Also why did we add the "impl" package to the project?

Hey @AykutSarac Thanks for the review, I have used useSearchParams from the next/navigation package which is supported in the app router, let me know why you think I should migrate it.
And I have installed "impl" package because of the following error:
Screenshot 2024-02-11 at 9 57 28 PM

@AykutSarac
Copy link
Owner

@zoosphar
Copy link
Contributor Author

It's recommended by Next.js, also fails the build. https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout

Okay, got it. So adding a suspense boundary to the component would suffice right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants