-
Notifications
You must be signed in to change notification settings - Fork 27.6k
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
Create next.js example for pullstate #20078
Conversation
Stats from current PRDefault Server Mode (Decrease detected ✓)General
Page Load Tests Overall decrease
|
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.081 | 2.058 | -0.02 |
/ avg req/sec | 1201.6 | 1215.06 | +13.46 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.077 | 1.098 | |
/error-in-render avg req/sec | 2321.3 | 2277.45 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
677f882d2ed8..34b9.js gzip | 12.8 kB | 12.8 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-3e8cb31..cddc.js gzip | 6.56 kB | 6.56 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 59 kB | 59 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
_app-7231d4b..5856.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-01375..90b6.js gzip | 3.69 kB | 3.69 kB | ✓ |
hooks-d4591d..e7c2.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-db223d9..dbd7.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..fd29.js gzip | 303 B | 303 B | ✓ |
withRouter-b..76ae.js gzip | 302 B | 302 B | ✓ |
Overall change | 8.31 kB | 8.31 kB | ✓ |
Client Build Manifests
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
_buildManifest.js gzip | 322 B | 322 B | ✓ |
Overall change | 322 B | 322 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
index.html gzip | 614 B | 614 B | ✓ |
link.html gzip | 620 B | 620 B | ✓ |
withRouter.html gzip | 608 B | 608 B | ✓ |
Overall change | 1.84 kB | 1.84 kB | ✓ |
Serverless Mode
General
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
buildDuration | 10.1s | 10.2s | |
nodeModulesSize | 82.5 MB | 82.5 MB | ✓ |
Client Bundles (main, webpack, commons)
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
677f882d2ed8..34b9.js gzip | 12.8 kB | 12.8 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-3e8cb31..cddc.js gzip | 6.56 kB | 6.56 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 59 kB | 59 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
_app-7231d4b..5856.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-01375..90b6.js gzip | 3.69 kB | 3.69 kB | ✓ |
hooks-d4591d..e7c2.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-db223d9..dbd7.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..fd29.js gzip | 303 B | 303 B | ✓ |
withRouter-b..76ae.js gzip | 302 B | 302 B | ✓ |
Overall change | 8.31 kB | 8.31 kB | ✓ |
Client Build Manifests
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
_buildManifest.js gzip | 322 B | 322 B | ✓ |
Overall change | 322 B | 322 B | ✓ |
Serverless bundles
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
_error.js | 1 MB | 1 MB | ✓ |
404.html | 2.67 kB | 2.67 kB | ✓ |
hooks.html | 1.92 kB | 1.92 kB | ✓ |
index.js | 1 MB | 1 MB | ✓ |
link.js | 1.06 MB | 1.06 MB | ✓ |
routerDirect.js | 1.05 MB | 1.05 MB | ✓ |
withRouter.js | 1.05 MB | 1.05 MB | ✓ |
Overall change | 5.16 MB | 5.16 MB | ✓ |
const instance = | ||
typeof window === 'undefined' | ||
? PullstateCore.instantiate({ ssr: true }) | ||
: PullstateCore.instantiate({ | ||
ssr: false, | ||
hydrateSnapshot: pageProps.hydrateSnapshot, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this going to create a new instance every time App
re-renders? Ignore my comment if that doesn't matter. But it might be bad if that means the previous state is ignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xeoneux Hi there 👋 and thank you for the PR!
Let's make sure to show the store working in different rendering methods, like in the with-redux
example, where the store is used for both SSR and static pages, and navigations work without any issues.
Hi @lfades thanks for the review, I have updated the example with a demo for ssg and ssr pages |
Stats from current PRDefault Server Mode (Decrease detected ✓)General
Page Load Tests Overall decrease
|
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.047 | 2.038 | -0.01 |
/ avg req/sec | 1221.57 | 1226.85 | +5.28 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.078 | 1.102 | |
/error-in-render avg req/sec | 2319.51 | 2267.6 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
677f882d2ed8..34b9.js gzip | 12.8 kB | 12.8 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-3e8cb31..cddc.js gzip | 6.56 kB | 6.56 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 59 kB | 59 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
_app-7231d4b..5856.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-01375..90b6.js gzip | 3.69 kB | 3.69 kB | ✓ |
hooks-d4591d..e7c2.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-db223d9..dbd7.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..fd29.js gzip | 303 B | 303 B | ✓ |
withRouter-b..76ae.js gzip | 302 B | 302 B | ✓ |
Overall change | 8.31 kB | 8.31 kB | ✓ |
Client Build Manifests
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
_buildManifest.js gzip | 322 B | 322 B | ✓ |
Overall change | 322 B | 322 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
index.html gzip | 614 B | 614 B | ✓ |
link.html gzip | 620 B | 620 B | ✓ |
withRouter.html gzip | 608 B | 608 B | ✓ |
Overall change | 1.84 kB | 1.84 kB | ✓ |
Serverless Mode
General
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
buildDuration | 9.9s | 9.9s | -41ms |
nodeModulesSize | 82.5 MB | 82.5 MB | ✓ |
Client Bundles (main, webpack, commons)
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
677f882d2ed8..34b9.js gzip | 12.8 kB | 12.8 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-3e8cb31..cddc.js gzip | 6.56 kB | 6.56 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 59 kB | 59 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
_app-7231d4b..5856.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-01375..90b6.js gzip | 3.69 kB | 3.69 kB | ✓ |
hooks-d4591d..e7c2.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-db223d9..dbd7.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..fd29.js gzip | 303 B | 303 B | ✓ |
withRouter-b..76ae.js gzip | 302 B | 302 B | ✓ |
Overall change | 8.31 kB | 8.31 kB | ✓ |
Client Build Manifests
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
_buildManifest.js gzip | 322 B | 322 B | ✓ |
Overall change | 322 B | 322 B | ✓ |
Serverless bundles
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
_error.js | 1 MB | 1 MB | ✓ |
404.html | 2.67 kB | 2.67 kB | ✓ |
hooks.html | 1.92 kB | 1.92 kB | ✓ |
index.js | 1 MB | 1 MB | ✓ |
link.js | 1.06 MB | 1.06 MB | ✓ |
routerDirect.js | 1.05 MB | 1.05 MB | ✓ |
withRouter.js | 1.05 MB | 1.05 MB | ✓ |
Overall change | 5.16 MB | 5.16 MB | ✓ |
Stats from current PRDefault Server Mode (Decrease detected ✓)General
Page Load Tests Overall decrease
|
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.158 | 2.19 | |
/ avg req/sec | 1158.64 | 1141.68 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.116 | 1.131 | |
/error-in-render avg req/sec | 2239.73 | 2211.37 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
677f882d2ed8..34b9.js gzip | 12.8 kB | 12.8 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-3e8cb31..cddc.js gzip | 6.56 kB | 6.56 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 59 kB | 59 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
_app-7231d4b..5856.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-01375..90b6.js gzip | 3.69 kB | 3.69 kB | ✓ |
hooks-d4591d..e7c2.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-db223d9..dbd7.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..fd29.js gzip | 303 B | 303 B | ✓ |
withRouter-b..76ae.js gzip | 302 B | 302 B | ✓ |
Overall change | 8.31 kB | 8.31 kB | ✓ |
Client Build Manifests
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
_buildManifest.js gzip | 322 B | 322 B | ✓ |
Overall change | 322 B | 322 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
index.html gzip | 614 B | 614 B | ✓ |
link.html gzip | 620 B | 620 B | ✓ |
withRouter.html gzip | 608 B | 608 B | ✓ |
Overall change | 1.84 kB | 1.84 kB | ✓ |
Serverless Mode
General
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
buildDuration | 10s | 9.8s | -229ms |
nodeModulesSize | 82.5 MB | 82.5 MB | ✓ |
Client Bundles (main, webpack, commons)
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
677f882d2ed8..34b9.js gzip | 12.8 kB | 12.8 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-3e8cb31..cddc.js gzip | 6.56 kB | 6.56 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 59 kB | 59 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
_app-7231d4b..5856.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-01375..90b6.js gzip | 3.69 kB | 3.69 kB | ✓ |
hooks-d4591d..e7c2.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-db223d9..dbd7.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..fd29.js gzip | 303 B | 303 B | ✓ |
withRouter-b..76ae.js gzip | 302 B | 302 B | ✓ |
Overall change | 8.31 kB | 8.31 kB | ✓ |
Client Build Manifests
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
_buildManifest.js gzip | 322 B | 322 B | ✓ |
Overall change | 322 B | 322 B | ✓ |
Serverless bundles
vercel/next.js canary | xeoneux/next.js canary | Change | |
---|---|---|---|
_error.js | 1 MB | 1 MB | ✓ |
404.html | 2.67 kB | 2.67 kB | ✓ |
hooks.html | 1.92 kB | 1.92 kB | ✓ |
index.js | 1 MB | 1 MB | ✓ |
link.js | 1.06 MB | 1.06 MB | ✓ |
routerDirect.js | 1.05 MB | 1.05 MB | ✓ |
withRouter.js | 1.05 MB | 1.05 MB | ✓ |
Overall change | 5.16 MB | 5.16 MB | ✓ |
import { useHydrate } from '../stores' | ||
|
||
export default function App({ Component, pageProps }) { | ||
const instance = useHydrate(pageProps.snapshot) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's give this another name, like useStore
.
<div | ||
style={{ | ||
backgroundColor: isDarkMode ? '#333' : '#CCC', | ||
color: isDarkMode ? '#CCC' : '#333', | ||
}} | ||
> | ||
<h1>Pullstate Demo</h1> | ||
|
||
<p>Dark Mode is {isDarkMode ? 'On' : 'Off'}</p> | ||
|
||
<button | ||
onClick={() => | ||
UIStore.update((s) => { | ||
s.isDarkMode = !s.isDarkMode | ||
}) | ||
} | ||
> | ||
Toggle Dark Mode | ||
</button> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This component should have links to the other pages, that's important to see how all pages work together while the app is running.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added 2 more suggestions 🙏
Going to close this as the PR is stale. Happy to merge when the changes are made. |
Any progress made on this? Really would like to use Pullstate with Next.JS but there are no good examples. |
@Raamzeez The PR was closed and examples are managed by the community, feel free to contribute |
No description provided.