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

Custom _app.js is being ignored when using React Server Components #36659

Closed
1 task done
chenraz opened this issue May 3, 2022 · 3 comments · Fixed by #36710
Closed
1 task done

Custom _app.js is being ignored when using React Server Components #36659

chenraz opened this issue May 3, 2022 · 3 comments · Fixed by #36710
Labels
bug Issue was opened via the bug report template.

Comments

@chenraz
Copy link

chenraz commented May 3, 2022

Verify canary release

  • I verified that the issue exists in Next.js canary release

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #123-Ubuntu SMP Fri Apr 8 09:10:54 UTC 2022
Binaries:
  Node: 16.14.0
  npm: 8.3.1
  Yarn: 1.22.5
  pnpm: 7.0.0
Relevant packages:
  next: 12.1.7-canary.0
  react: 18.1.0
  react-dom: 18.1.0

What browser are you using? (if relevant)

Chrome, Firefox

How are you deploying your application? (if relevant)

next start

Describe the Bug

Custom app on _app.tsx is ignored, when using React Server Components (with fresh create-next-app installation)

Expected Behavior

Elements returned from custom app function on _app.tsx should be rendered on screen.

To Reproduce

Github repo to reproduce:
https://github.com/chenraz/nextjs-rsc.git

  1. Create next app:
    pnpm create next-app@latest -- --ts

  2. Enable experimental RSC on next.config.js:

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  experimental: {
    runtime: 'nodejs',
    serverComponents: true,
  },
}

module.exports = nextConfig

  1. Add layout to _app.tsx:
import '../styles/globals.css'
import type { AppProps } from 'next/app'

function MyApp({ Component, pageProps }: AppProps) {
  return <div>
    <span>ADD SOMETHING BEFORE</span>
    <Component {...pageProps} />
  </div>
}

export default MyApp

So far so good - custom app layout is rendered on screen.

  1. Modify pages/index.tsx to pages/index.server.tsx

Custom app layout does not render on screen.

@chenraz chenraz added the bug Issue was opened via the bug report template. label May 3, 2022
@toxicFork
Copy link

I had a similar issue and creating an _app.server.tsx makes it work, to some extent. There are many other issues after that, though.

@huozhi huozhi mentioned this issue May 5, 2022
3 tasks
@kodiakhq kodiakhq bot closed this as completed in #36710 May 5, 2022
kodiakhq bot pushed a commit that referenced this issue May 5, 2022
Fixes #36659

`App` is alreay included in `ServerComponentWrapper`

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
@chenraz
Copy link
Author

chenraz commented May 8, 2022

Thanks for the fix, it solves the problem

@github-actions
Copy link
Contributor

github-actions bot commented Jun 8, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants