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

Example using nextjs 13.4 App Router #47

Open
BDive opened this issue May 6, 2023 · 12 comments
Open

Example using nextjs 13.4 App Router #47

BDive opened this issue May 6, 2023 · 12 comments

Comments

@BDive
Copy link

BDive commented May 6, 2023

Hi, An example using the nextjs 13.4 App Router would be great - running into multiple compile and runtime issues porting page to app router.

Thanks

@getdir
Copy link

getdir commented May 12, 2023

+1

@Ali-Aref
Copy link

Ali-Aref commented May 14, 2023

+1 same here! any updates?

@accountsware
Copy link

+1

@yusrandi
Copy link

yusrandi commented Jun 1, 2023

+1 same here! any updates?

@dzabdelhak
Copy link

+1

@nestorzamili
Copy link

+1 same here! any updates?

@juanlopez87
Copy link

Same here. Is there any update??

@palerique
Copy link

There is a guy that forked Sakai and did part of the adaptation to Nextjs 13.4: https://github.com/buraksaglam089/sakai-react

@Vicidevs
Copy link

Vicidevs commented Jul 6, 2023

Same here

@thomassonobe
Copy link

+1

@CretuCristianIonut
Copy link

CretuCristianIonut commented Oct 31, 2023

I used this as an inspiration :
https://nextjs.org/docs/app/api-reference/components/link#href-required
and https://nextjs.org/docs/app/api-reference/file-conventions/page#params-optional

Folders need to be defined :

pages- folder
  details - folder
      [slug] - folder
          page.tsx -file - detailed element page - that is received dynamically based on params
       page.tsx - file - main details page

Paths in browser desired:

localhost:3000/pages/details
localhost:3000/pages/details/1

Code for main details page where we add some links :

'use client';
import Link from 'next/link';
import { useRouter } from 'next/navigation'

export default function Home() {
    return (
      <>
        <header>
          <h1>Home</h1>
        </header>
        <main>
          <h2>All Posts</h2>
          <ol>
              <li key="1">
                <Link href={`/pages/details/my-first-post`}>
                  un link catre details / 1
                </Link>
              </li>
              <li key="2">
                <Link href={`/pages/details/my-second-post`}>
                  un link catre details / 2
                </Link>
              </li>
          </ol>
        </main>
      </>
    );
  }

Detail element page - coming dynamically from slug attr in params:

'use client';
import Link from 'next/link';
import { useRouter } from 'next/navigation'

export default function Details({ params, searchParams }: {
    params: { slug: string }
    searchParams: { [key: string]: string | string[] | undefined }
  }) {
    const router = useRouter();
    console.log(params);
    console.log(searchParams);
    return (
        <>
        <header>
            <Link href="/">
            Home
            </Link>
        </header>
        <main>
            <article>
            <h1>We received param.slug=`{params.slug}`</h1>
            <p>this can be anything</p>
            </article>
        </main>
        </>
    );
}

I hope this helps !

@melloware
Copy link
Member

melloware commented Aug 15, 2024

Sample has been added here on how to make PrimeReact + Next + AppRouter + Tailwind: https://github.com/primefaces/primereact-examples/tree/main/nextjs-app-router-styled-tailwind

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

No branches or pull requests