`next/app` as functional component
See original GitHub issueFeature request
Problem
Functional components yield a more performant and readable code. It’s been hinted by React team that class’es may be split into a separate package in the near future. It would be nice for Next.js to provide a way to create apps without classes. Currently it’s not possible as _app.js and _document.js require to extend Next’s React classes.
Solution
If Next’s controlling components can be rewritten with React Hooks, the entire Next app should consist of functional components by default. Perhaps we could have a version that uses that style as an opt-in for backwards compatibility.
Alternative
I am considering rewriting the above-mentioned components in my project folder, but I fear that it may cause some issues.
Additional context
This is pretty much it.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:126
- Comments:28 (11 by maintainers)
Top Results From Across the Web
Advanced Features: Custom `App` - Next.js
The Component prop is the active page , so whenever you navigate between routes, Component will change to the new page . Therefore,...
Read more >Next.Js Series #4 - What is the custom 'App' component in ...
We are going to introduce the custom 'App' component in Next.Js and its use cases. When we used 'create-next-app' command to create our...
Read more >How to manage function component state in NextJS?
I wanna to access a state variable of component ...
Read more >Next.js — Start web development with Next.js & create-next-app
After you create your application with create-next-app it is ready to use in seconds. ... Functional vs Class Components in React 16.9.
Read more >Best practices to increase the speed for Next.js apps
This function will be called by the server on every request, returning an object that will be passed to the page component as...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Here is the perfect _app type.
https://github.com/myeongjae-kim/next-js-with-typescript-valid-app-type
@medmin please don’t spam issues.
You can already use hooks in
_app.jsby doing:We’ve already made changes to Next.js to allow the exported component itself to be a functional component. However this would break
withRouteras that still uses legacy context for backwards compat reasons.