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

Clarify data fetching documentation on calling API routes. #19748

Merged
merged 1 commit into from Dec 2, 2020

Conversation

leerob
Copy link
Member

@leerob leerob commented Dec 2, 2020

We've received some feedback that the current note about calling API routes inside gSP/gSSP is confusing. This updates the wording to make it clear you can still use fetch in your application, and also to not say you "import" an API route. You import the logic inside the route.

@ijjk
Copy link
Member

ijjk commented Dec 2, 2020

Stats from current PR

Default Server Mode (Decrease detected ✓)
General
vercel/next.js canary vercel/next.js leerob-patch-1 Change
buildDuration 8.7s 8.7s -67ms
nodeModulesSize 82.3 MB 82.3 MB
Page Load Tests Overall decrease ⚠️
vercel/next.js canary vercel/next.js leerob-patch-1 Change
/ failed reqs 0 0
/ total time (seconds) 1.725 1.753 ⚠️ +0.03
/ avg req/sec 1449.3 1425.85 ⚠️ -23.45
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.064 1.094 ⚠️ +0.03
/error-in-render avg req/sec 2349.51 2285.63 ⚠️ -63.88
Client Bundles (main, webpack, commons)
vercel/next.js canary vercel/next.js leerob-patch-1 Change
677f882d2ed8..8b6e.js gzip 12.8 kB 12.8 kB
framework.HASH.js gzip 39 kB 39 kB
main-3c9ff84..1d7c.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 vercel/next.js leerob-patch-1 Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary vercel/next.js leerob-patch-1 Change
_app-7231d4b..5856.js gzip 1.28 kB 1.28 kB
_error-fca3d..2eb1.js gzip 3.44 kB 3.44 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..924c.js gzip 284 B 284 B
withRouter-7..c13d.js gzip 284 B 284 B
Overall change 8.01 kB 8.01 kB
Client Build Manifests
vercel/next.js canary vercel/next.js leerob-patch-1 Change
_buildManifest.js gzip 321 B 321 B
Overall change 321 B 321 B
Rendered Page Sizes
vercel/next.js canary vercel/next.js leerob-patch-1 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 vercel/next.js leerob-patch-1 Change
buildDuration 10.1s 10.1s ⚠️ +15ms
nodeModulesSize 82.3 MB 82.3 MB
Client Bundles (main, webpack, commons)
vercel/next.js canary vercel/next.js leerob-patch-1 Change
677f882d2ed8..8b6e.js gzip 12.8 kB 12.8 kB
framework.HASH.js gzip 39 kB 39 kB
main-3c9ff84..1d7c.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 vercel/next.js leerob-patch-1 Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary vercel/next.js leerob-patch-1 Change
_app-7231d4b..5856.js gzip 1.28 kB 1.28 kB
_error-fca3d..2eb1.js gzip 3.44 kB 3.44 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..924c.js gzip 284 B 284 B
withRouter-7..c13d.js gzip 284 B 284 B
Overall change 8.01 kB 8.01 kB
Client Build Manifests
vercel/next.js canary vercel/next.js leerob-patch-1 Change
_buildManifest.js gzip 321 B 321 B
Overall change 321 B 321 B
Serverless bundles
vercel/next.js canary vercel/next.js leerob-patch-1 Change
_error.js 997 kB 997 kB
404.html 2.67 kB 2.67 kB
hooks.html 1.92 kB 1.92 kB
index.js 998 kB 998 kB
link.js 1.05 MB 1.05 MB
routerDirect.js 1.04 MB 1.04 MB
withRouter.js 1.04 MB 1.04 MB
Overall change 5.14 MB 5.14 MB
Commit: 9d53c42

@kodiakhq kodiakhq bot merged commit 8c2cb46 into canary Dec 2, 2020
@kodiakhq kodiakhq bot deleted the leerob-patch-1 branch December 2, 2020 16:23
@tmerlet
Copy link

tmerlet commented Dec 12, 2020

strangely I'm still seeing the old text?
"Note: You should not use fetch() to call an API route in your application. Instead, directly import the API route and call its function yourself. You may need to slightly refactor your code for this approach."
https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation

@vercel vercel locked as resolved and limited conversation to collaborators Jan 29, 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.

None yet

4 participants