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

Update the Next.js Pages guide to use the latest tooling #13001

Merged
merged 4 commits into from
Feb 27, 2024

Conversation

dario-piotrowicz
Copy link
Member

@dario-piotrowicz dario-piotrowicz commented Feb 15, 2024

update the Next.js Pages guide to use the latest tooling consistently to the changes made in C3: cloudflare/workers-sdk#5009

Such changes include:

  • renaming setupDevBindings with setupDevPlatform
  • updating the bindings access to use getRequestContext
  • update the C3 scaffolded script names
  • update the env.d.ts file content

resolves #12972

Copy link

cloudflare-workers-and-pages bot commented Feb 15, 2024

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7434eac
Status: ✅  Deploy successful!
Preview URL: https://2fbcfaa7.cloudflare-docs-7ou.pages.dev
Branch Preview URL: https://nextjs-guide-utils-update.cloudflare-docs-7ou.pages.dev

View logs

@@ -47,7 +47,7 @@ Git integration cannot currently be added to existing Pages applications. If you

## Configure and deploy a project without C3

If you already have a Next.js project or wish to manually create and deploy one without using C3, Cloudflare recommends that you use `@cloudflare/next-on-pages` and refer to its [README](https://github.com/cloudflare/next-on-pages/tree/main/packages/next-on-pages#cloudflarenext-on-pages) for instructions and additional information to help you develop and deploy your project.
If you already have a Next.js project or wish to manually create and deploy one without using C3, Cloudflare recommends that you use `@cloudflare/next-on-pages` and refer to its [README](https://github.com/cloudflare/next-on-pages/blob/3846730c4a0d12/packages/next-on-pages#cloudflarenext-on-pages) for instructions and additional information to help you develop and deploy your project.
Copy link
Member Author

Choose a reason for hiding this comment

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

@deadlypants1973 Instead of having generic github links I thought it'd be more secure to have permalinks
(meaning that if the github files change the links keep pointing to the same content, instead of having links pointing to content that might change over time)

Please let me know if you agree 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

@dario-piotrowicz I recommend against this as the link will take people to a stale version of the doc over time. What I recommend instead is that you create a manual anchor in the readme.md via <a name="manual-installation"> for example and refer to it here. Manual anchors are unlikely to break easily so you get both the stability of the link as ability to refresh the readme.md content without having to come back here to update the link.

Copy link
Member Author

@dario-piotrowicz dario-piotrowicz Feb 22, 2024

Choose a reason for hiding this comment

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

The #cloudflarenext-on-pages is actually unnecessary, it is pointing to the readme title (and all it does is making github scroll the user to the beginning of the README), if you're ok with it I might as well just remove it, simply point to the file and revert back the blob/ change 🙂

### Set up bindings for a deployed application

To access bindings in a deployed application, you will need to [configure](/pages/functions/bindings/) any necessary bindings and connect them to your project via your project's settings page in the Cloudflare dashboard.

### Add bindings to Typescript projects
Copy link
Member Author

Choose a reason for hiding this comment

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

I've moved this section up because, for typescript project it is a prerequisite of the Access bindings in the application one

Copy link
Contributor

@IgorMinar IgorMinar left a comment

Choose a reason for hiding this comment

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

a few suggestions but the rest looks great! Thanks Dario

@@ -47,7 +47,7 @@ Git integration cannot currently be added to existing Pages applications. If you

## Configure and deploy a project without C3

If you already have a Next.js project or wish to manually create and deploy one without using C3, Cloudflare recommends that you use `@cloudflare/next-on-pages` and refer to its [README](https://github.com/cloudflare/next-on-pages/tree/main/packages/next-on-pages#cloudflarenext-on-pages) for instructions and additional information to help you develop and deploy your project.
If you already have a Next.js project or wish to manually create and deploy one without using C3, Cloudflare recommends that you use `@cloudflare/next-on-pages` and refer to its [README](https://github.com/cloudflare/next-on-pages/blob/3846730c4a0d12/packages/next-on-pages#cloudflarenext-on-pages) for instructions and additional information to help you develop and deploy your project.
Copy link
Contributor

Choose a reason for hiding this comment

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

@dario-piotrowicz I recommend against this as the link will take people to a stale version of the doc over time. What I recommend instead is that you create a manual anchor in the readme.md via <a name="manual-installation"> for example and refer to it here. Manual anchors are unlikely to break easily so you get both the stability of the link as ability to refresh the readme.md content without having to come back here to update the link.

@@ -108,7 +108,7 @@ Projects created with C3 have bindings for local development set up by default.

{{</Aside>}}

To set up bindings for use in local development, you will use the `setupDevBindings` function provided by [`@cloudflare/next-on-pages/next-dev`](https://github.com/cloudflare/next-on-pages/tree/main/internal-packages/next-dev). This function allows you to specify bindings that work locally, and are accessed the same way remote bindings are.
To set up bindings for use in local development, you will use the `setupDevPlatform` function provided by [`@cloudflare/next-on-pages/next-dev`](https://github.com/cloudflare/next-on-pages/blob/3846730c4a0d12/internal-packages/next-dev). This function, tries to read the project's [`wrangler.toml`](/workers/wrangler/configuration/) file and based on it sets up a platform emulation that your Next.js application can make use of locally.
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

Copy link
Member Author

Choose a reason for hiding this comment

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

Here it is already pointing to the readme itself, so if it's ok by you I'll just revert the blob/ part to /tree/main 🙂

dario-piotrowicz and others added 4 commits February 23, 2024 19:07
update the Next.js Pages guide to use the latest tooling consistently
to the changes made in C3: cloudflare/workers-sdk#5009

Such changes include:
 - renaming `setupDevBindings` with `setupDevPlatform`
 - updating the bindings access to use `getRequestContext`
 - update the C3 scaffolded script names
 - update the `env.d.ts` file content
Co-authored-by: Kate Tungusova <70746074+deadlypants1973@users.noreply.github.com>
@github-actions github-actions bot added the product:workers Related to Workers product label Feb 25, 2024
@github-actions github-actions bot removed the product:workers Related to Workers product label Feb 25, 2024
@dario-piotrowicz dario-piotrowicz merged commit bc46b7e into production Feb 27, 2024
12 checks passed
@dario-piotrowicz dario-piotrowicz deleted the nextjs-guide-utils-update branch February 27, 2024 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update Next.js guide to include setupDevPlatform and getRequestContext
3 participants