-
Notifications
You must be signed in to change notification settings - Fork 538
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
Support plan for Next.js app router #4069
Comments
Hi @meiyingqishi 👋 We support Next.js and you can also access our internal example of Next.js to see how we set up the project and utilize Primer React components there. I'm going to go ahead and close this issue but please report back if you are having any specific issues with compatibility of our components with Next.js. |
Thank you for your response. @broccolinisoup
|
Hi @meiyingqishi 👋 Sorry when I read the issue, it didn't occur to me that you are talking about the new app router and React Server Components! I appreciate you provided details. I am chatting about this with my team to see how we can support it. I'll re-open the issue and rename it to "Support for Next.js app router" and you can subscribe to this issue to get updates on the support. Thanks for bringing it up and raising the issue. |
Hi @meiyingqishi, we have another issue opened that dives deeper into the server components, feel free to have a read. We also have a draft PR that addresses the issue you mentioned here. |
Hi there! 👋 Just wanted to follow up on this now that: #4128 is merged and available in Components should be directly usable from Going to close this out but feel free to leave a comment or provide any feedback if this is not working as expected! |
Thank you! It worked. |
👋 Pardon the ignorance. But how does one use it though? I followed https://nextjs.org/docs/app/building-your-application/styling/css-in-js#styled-components to get styled-components into my App router based Next.js v14 app. Now that there's no longer an <ThemeProvider>
<BaseStyles>
...
</BaseStyles>
</ThemeProvider> If someone has an example that combines |
import {
BaseStyles,
ThemeProvider,
} from "@primer/react";
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body>
<ThemeProvider>
<BaseStyles>{children}</BaseStyles>
</ThemeProvider>
</body>
</html>
);
}
import {
Button,
} from "@primer/react";
export default function Home() {
return (
<main>
<Button>Hello Button</Button>
</main>
);
}
|
@meiyingqishi That doesn't solve the SSR problem. You get CSS-in-JS where the styling is injected at runtime, on the client. You actually get pretty far with: import StyledComponentsRegistry from "@/lib/registry";
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body>
<StyledComponentsRegistry>
<ThemeProvider>
<BaseStyles>
<Inner>{children}</Inner>
</BaseStyles>
</ThemeProvider>
</StyledComponentsRegistry>
</body>
</html>
);
} It works. But I get very strange warnings in development mode that I don't understand. |
Hi there, @peterbe! We have an App Router example over at: https://github.com/primer/react/tree/main/examples/app-router if it's helpful (there is one change that needs to happen from #4307) Would love to hear any feedback you have for that example and if it works or doesn't work for your use-case. I believe it should handle the SSR case for styles using the guide from Next.js but let me know if there are any issues! |
Yay! Now I can't even remember how I stumbled into https://github.com/primer/react/tree/main/examples/nextjs in the first place. Perhaps by a Google search??
I got things working. SSR and all. Used your draft from #4307 and not a warning or error in sight. What tripped me up, and can be seen in my screenshot above, was that the link on https://primer.style/react/getting-started#static-css-rendering to styled-components made me think I had to use |
Hi @joshblack , I accidentally tried the primer design system again and found there's still an issue. When using individual components like <ActionList>
<ActionList.Item>Copy link</ActionList.Item>
<ActionList.Item>Quote reply</ActionList.Item>
<ActionList.Item>Edit comment</ActionList.Item>
</ActionList> The issue lies with the |
Is there a plan for Primer Design System components to support Next.js?
Using client-side components on Next.js has become quite painful.
The text was updated successfully, but these errors were encountered: