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

[Docs] Focus on useRouter #14515

Merged
merged 5 commits into from
Jun 25, 2020
Merged

[Docs] Focus on useRouter #14515

merged 5 commits into from
Jun 25, 2020

Conversation

lfades
Copy link
Member

@lfades lfades commented Jun 24, 2020

[ch4109]

Closes #14500

Our current docs for next/router use examples from both useRouter and import Router from 'next/router', with this PR I'm unifying the API into useRouter (withRouter is still going to be mentioned multiple times as it is the HOC alternative) and no longer mentioning that you can import a global Router object from next/router, not sure if I should mention it at least once but that didn't seem to be required.

I also did some structural changes to the docs for next/router, now every method starts with a description, then the implementation and explanation of the parameters of the method, and then the usage example, because every method uses the same Usage title the hash for them would be something like #usage, #usage-1, #usage-2, e.t.c, so I'm not very happy with this but it looks good.

Feedback wanted 🙏

@ijjk
Copy link
Member

ijjk commented Jun 24, 2020

Stats from current PR

Default Server Mode (Decrease detected ✓)
General
vercel/next.js canary lfades/next.js docs/unify-router Change
buildDuration 12.3s 12.9s ⚠️ +574ms
nodeModulesSize 67.1 MB 67.1 MB
Page Load Tests Overall decrease ⚠️
vercel/next.js canary lfades/next.js docs/unify-router Change
/ failed reqs 0 0
/ total time (seconds) 2.045 2.058 ⚠️ +0.01
/ avg req/sec 1222.71 1214.56 -8.15
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.229 1.236 ⚠️ +0.01
/error-in-render avg req/sec 2033.65 2022.87 -10.78
Client Bundles (main, webpack, commons)
vercel/next.js canary lfades/next.js docs/unify-router Change
main-HASH.js gzip 6.49 kB 6.49 kB
webpack-HASH.js gzip 746 B 746 B
19b7e98f51cc..14a7.js gzip 10.7 kB 10.7 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 57.1 kB 57.1 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary lfades/next.js docs/unify-router Change
main-HASH.module.js gzip 5.57 kB 5.57 kB
webpack-HASH..dule.js gzip 746 B 746 B
19b7e98f51cc..dule.js gzip 7.07 kB 7.07 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.5 kB 52.5 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary lfades/next.js docs/unify-router Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Build Manifests
vercel/next.js canary lfades/next.js docs/unify-router Change
_buildManifest.js gzip 267 B 267 B
_buildManife..dule.js gzip 272 B 272 B
Overall change 539 B 539 B
Rendered Page Sizes
vercel/next.js canary lfades/next.js docs/unify-router Change
index.html gzip 954 B 954 B
link.html gzip 962 B 962 B
withRouter.html gzip 947 B 947 B
Overall change 2.86 kB 2.86 kB

Serverless Mode
General
vercel/next.js canary lfades/next.js docs/unify-router Change
buildDuration 13.5s 11s -2.4s
nodeModulesSize 67.1 MB 67.1 MB
Client Bundles (main, webpack, commons)
vercel/next.js canary lfades/next.js docs/unify-router Change
main-HASH.js gzip 6.49 kB 6.49 kB
webpack-HASH.js gzip 746 B 746 B
19b7e98f51cc..14a7.js gzip 10.7 kB 10.7 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 57.1 kB 57.1 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary lfades/next.js docs/unify-router Change
main-HASH.module.js gzip 5.57 kB 5.57 kB
webpack-HASH..dule.js gzip 746 B 746 B
19b7e98f51cc..dule.js gzip 7.07 kB 7.07 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.5 kB 52.5 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary lfades/next.js docs/unify-router Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Build Manifests
vercel/next.js canary lfades/next.js docs/unify-router Change
_buildManifest.js gzip 267 B 267 B
_buildManife..dule.js gzip 272 B 272 B
Overall change 539 B 539 B
Serverless bundles
vercel/next.js canary lfades/next.js docs/unify-router Change
_error.js 875 kB 875 kB
404.html 4.17 kB 4.17 kB
hooks.html 3.79 kB 3.79 kB
index.js 876 kB 876 kB
link.js 916 kB 916 kB
routerDirect.js 908 kB 908 kB
withRouter.js 908 kB 908 kB
Overall change 4.49 MB 4.49 MB
Commit: b2afd1c

Copy link
Member

@chibicode chibicode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just a few changes requested.

@lfades lfades requested a review from chibicode June 25, 2020 23:17
@ijjk
Copy link
Member

ijjk commented Jun 25, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General
vercel/next.js canary lfades/next.js docs/unify-router Change
buildDuration 12.9s 12.9s ⚠️ +13ms
nodeModulesSize 67.2 MB 67.2 MB
Page Load Tests Overall increase ✓
vercel/next.js canary lfades/next.js docs/unify-router Change
/ failed reqs 0 0
/ total time (seconds) 2.186 2.138 -0.05
/ avg req/sec 1143.67 1169.57 ⚠️ +25.9
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.449 1.429 -0.02
/error-in-render avg req/sec 1725.36 1749.38 ⚠️ +24.02
Client Bundles (main, webpack, commons)
vercel/next.js canary lfades/next.js docs/unify-router Change
main-HASH.js gzip 6.5 kB 6.5 kB
webpack-HASH.js gzip 746 B 746 B
19b7e98f51cc..96f3.js gzip 10.7 kB 10.7 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 57.1 kB 57.1 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary lfades/next.js docs/unify-router Change
main-HASH.module.js gzip 5.59 kB 5.59 kB
webpack-HASH..dule.js gzip 746 B 746 B
19b7e98f51cc..dule.js gzip 7.08 kB 7.08 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.6 kB 52.6 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary lfades/next.js docs/unify-router Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Build Manifests
vercel/next.js canary lfades/next.js docs/unify-router Change
_buildManifest.js gzip 267 B 267 B
_buildManife..dule.js gzip 272 B 272 B
Overall change 539 B 539 B
Rendered Page Sizes
vercel/next.js canary lfades/next.js docs/unify-router Change
index.html gzip 955 B 955 B
link.html gzip 961 B 961 B
withRouter.html gzip 947 B 947 B
Overall change 2.86 kB 2.86 kB

Serverless Mode
General
vercel/next.js canary lfades/next.js docs/unify-router Change
buildDuration 13.6s 13.7s ⚠️ +56ms
nodeModulesSize 67.2 MB 67.2 MB
Client Bundles (main, webpack, commons)
vercel/next.js canary lfades/next.js docs/unify-router Change
main-HASH.js gzip 6.5 kB 6.5 kB
webpack-HASH.js gzip 746 B 746 B
19b7e98f51cc..96f3.js gzip 10.7 kB 10.7 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 57.1 kB 57.1 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary lfades/next.js docs/unify-router Change
main-HASH.module.js gzip 5.59 kB 5.59 kB
webpack-HASH..dule.js gzip 746 B 746 B
19b7e98f51cc..dule.js gzip 7.08 kB 7.08 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.6 kB 52.6 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary lfades/next.js docs/unify-router Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Build Manifests
vercel/next.js canary lfades/next.js docs/unify-router Change
_buildManifest.js gzip 267 B 267 B
_buildManife..dule.js gzip 272 B 272 B
Overall change 539 B 539 B
Serverless bundles
vercel/next.js canary lfades/next.js docs/unify-router Change
_error.js 875 kB 875 kB
404.html 4.17 kB 4.17 kB
hooks.html 3.79 kB 3.79 kB
index.js 876 kB 876 kB
link.js 916 kB 916 kB
routerDirect.js 908 kB 908 kB
withRouter.js 908 kB 908 kB
Overall change 4.49 MB 4.49 MB
Commit: 8f0737b

@ijjk
Copy link
Member

ijjk commented Jun 25, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General
vercel/next.js canary lfades/next.js docs/unify-router Change
buildDuration 11.4s 10.9s -491ms
nodeModulesSize 67.2 MB 67.2 MB
Page Load Tests Overall increase ✓
vercel/next.js canary lfades/next.js docs/unify-router Change
/ failed reqs 0 0
/ total time (seconds) 2.071 1.77 -0.3
/ avg req/sec 1207.05 1412.21 ⚠️ +205.16
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.273 1.108 -0.16
/error-in-render avg req/sec 1963.98 2256.75 ⚠️ +292.77
Client Bundles (main, webpack, commons)
vercel/next.js canary lfades/next.js docs/unify-router Change
main-HASH.js gzip 6.5 kB 6.5 kB
webpack-HASH.js gzip 746 B 746 B
19b7e98f51cc..96f3.js gzip 10.7 kB 10.7 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 57.1 kB 57.1 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary lfades/next.js docs/unify-router Change
main-HASH.module.js gzip 5.59 kB 5.59 kB
webpack-HASH..dule.js gzip 746 B 746 B
19b7e98f51cc..dule.js gzip 7.08 kB 7.08 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.6 kB 52.6 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary lfades/next.js docs/unify-router Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Build Manifests
vercel/next.js canary lfades/next.js docs/unify-router Change
_buildManifest.js gzip 267 B 267 B
_buildManife..dule.js gzip 272 B 272 B
Overall change 539 B 539 B
Rendered Page Sizes
vercel/next.js canary lfades/next.js docs/unify-router Change
index.html gzip 955 B 955 B
link.html gzip 961 B 961 B
withRouter.html gzip 947 B 947 B
Overall change 2.86 kB 2.86 kB

Serverless Mode
General
vercel/next.js canary lfades/next.js docs/unify-router Change
buildDuration 10.4s 10.9s ⚠️ +548ms
nodeModulesSize 67.2 MB 67.2 MB
Client Bundles (main, webpack, commons)
vercel/next.js canary lfades/next.js docs/unify-router Change
main-HASH.js gzip 6.5 kB 6.5 kB
webpack-HASH.js gzip 746 B 746 B
19b7e98f51cc..96f3.js gzip 10.7 kB 10.7 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 57.1 kB 57.1 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary lfades/next.js docs/unify-router Change
main-HASH.module.js gzip 5.59 kB 5.59 kB
webpack-HASH..dule.js gzip 746 B 746 B
19b7e98f51cc..dule.js gzip 7.08 kB 7.08 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.6 kB 52.6 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary lfades/next.js docs/unify-router Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Build Manifests
vercel/next.js canary lfades/next.js docs/unify-router Change
_buildManifest.js gzip 267 B 267 B
_buildManife..dule.js gzip 272 B 272 B
Overall change 539 B 539 B
Serverless bundles
vercel/next.js canary lfades/next.js docs/unify-router Change
_error.js 875 kB 875 kB
404.html 4.17 kB 4.17 kB
hooks.html 3.79 kB 3.79 kB
index.js 876 kB 876 kB
link.js 916 kB 916 kB
routerDirect.js 908 kB 908 kB
withRouter.js 908 kB 908 kB
Overall change 4.49 MB 4.49 MB
Commit: 42d6b79

@kodiakhq kodiakhq bot merged commit c6dc34e into vercel:canary Jun 25, 2020
rokinsky pushed a commit to rokinsky/next.js that referenced this pull request Jul 11, 2020
[ch4109]

Closes vercel#14500

Our current docs for `next/router` use examples from both `useRouter` and `import Router from 'next/router'`, with this PR I'm unifying the API into `useRouter` (`withRouter` is still going to be mentioned multiple times as it is the HOC alternative) and no longer mentioning that you can import a global `Router` object from `next/router`, not sure if I should mention it at least once but that didn't seem to be required.

I also did some structural changes to the docs for `next/router`, now every method starts with a description, then the implementation and explanation of the parameters of the method, and then the usage example, because every method uses the same `Usage` title the hash for them would be something like `#usage`, `#usage-1`, `#usage-2`, e.t.c, so I'm not very happy with this but it looks good.

Feedback wanted 🙏
@vercel vercel locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update next/router docs
3 participants