Skip to content

Documentation "highly recommends" an undocumented feature: serverless target #20487

@SylvainGarrigues

Description

@SylvainGarrigues

Bug report

Describe the bug

From the documentation:

server target

This is the default target, however, we highly recommend the serverless target.

It is explained that the serverless target will output autonomous modules, one per page, which export kind of wrappers around the http framework and therefore can be used in any cloud serverless function provider (e.g. Google Cloud Functions).

This does work indeed, but then the client code tries to fetch _next/data/{buildID}/{somepage}.json which the documentation doesn't mention.

Therefore, the documentation highly recommends an undocumented feature, which is confusing.

To Reproduce

  1. Read the doc and contemplate how it is highly recommended to deploy with the serverless target and use the generated modules
  2. Make use of the render method of (for instance) index.js from the build output in .next/serverless/pages/ in the code of a function of your favorite serverless function cloud provider (e.g. Google Cloud Functions)
  3. Host .next/static in a _next/static folder so that example.com/static/ uses it, and have example.com/ be served by the cloud function
  4. Repeat for other routes (for instance map /another to another cloud function which uses require('serverless/another.js').default.render
  5. Open example.com in the browser and in the console watch the browser fail to fetch _next/data/{buildID}/another.json and force a full reload by redirecting to /another instead of using client-side routing navigation

Expected behavior

  • Explain in the documentation what is needed to deploy the next.js framework in this highly recommended serverless configuration: access to disk for caching (and how to disable it in next.config.js), routes to be setup for _next/data and methods to be used (renderReqToHTML ?): not documenting this makes the serverless target kind of pointless while you highly recommend it in the same time
  • Please do not merely point to non-official projets (e.g. serverless-next)

System information

N/A (applies to all systems)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue was opened via the bug report template.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions