Skip to content

[Workers KV] Improving KV getting started guide #22573

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

Open
wants to merge 3 commits into
base: production
Choose a base branch
from

Conversation

Oxyjun
Copy link
Contributor

@Oxyjun Oxyjun commented May 20, 2025

Summary

  1. Adding "Deploy to Cloudflare" button.
  2. Improving the actual code for index.ts so that it's more obvious to see how it gets used in an application.
  3. Improving general structure (e.g. splitting step 6 into two more substeps of the guide to make it clearer.
  4. Adding summary frontmatter to provide context on what we're trying to achieve.
  5. Adding updated frontmatter to start tracking when the tutorial has been last updated.
  6. Using more tangible code examples throughout, rather than keeping it abstract with "VALUE" and "KEY".

Screenshots (optional)

Documentation checklist

  • The documentation style guide has been adhered to.
  • If a larger change - such as adding a new page- an issue has been opened in relation to any incorrect or out of date information that this PR fixes.
  • Files which have changed name or location have been allocated redirects.

Copy link
Contributor

hyperlint-ai bot commented May 20, 2025

Howdy and thanks for contributing to our repo. The Cloudflare team reviews new, external PRs within two (2) weeks. If it's been two weeks or longer without any movement, please tag the PR Assignees in a comment.

We review internal PRs within 1 week. If it's something urgent or has been sitting without a comment, start a thread in the Developer Docs space internally.


PR Change Summary

Enhanced the Workers KV getting started guide with improved clarity and usability.

  • Added a 'Deploy to Cloudflare' button for quick setup.
  • Improved code examples for better understanding and practical application.
  • Reorganized the guide structure for clarity, including splitting steps into substeps.
  • Introduced frontmatter for tracking updates and providing context.

Modified Files

  • src/content/docs/kv/get-started.mdx

How can I customize these reviews?

Check out the Hyperlint AI Reviewer docs for more information on how to customize the review.

If you just want to ignore it on this PR, you can add the hyperlint-ignore label to the PR. Future changes won't trigger a Hyperlint review.

Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add hyperlint-ignore to the PR to ignore the link check for this PR.

Copy link
Contributor

This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:

Pattern Owners
/src/content/docs/kv/ @elithrar, @thomasgauvin, @rts-rob, @oxyjun, @cloudflare/pcx-technical-writing

@@ -1,11 +1,14 @@
---
title: Getting started
pcx_content_type: get-started
summary: |
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean this or description? Was curious as I was not expecting a summary to appear at the top of the page. I think I've only seen this used before in specific cases such as Snippets or Rules examples (like this)

Comment on lines +146 to +154
Add the following to your configuration file in your kv_namespaces array:
{
"kv_namespaces": [
{
"binding": "USERS_NOTIFICATION_CONFIG",
"id": "<BINDING_ID>"
}
]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Just checking: this is intended to appear inside the output, right? Or would it be a separate 2?

</Details>

:::note
To view the value directly within the terminal, you use the `--text` flag.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
To view the value directly within the terminal, you use the `--text` flag.
To view the value directly within the terminal, use the `--text` flag.

Copy link
Contributor

Choose a reason for hiding this comment

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

If it's referring to the command above, maybe adding the sentence to the end of the paragraph in line 292 could be more direct.


</Steps>

You can add a `--preview` flag to interact with a preview namespace instead of a production namespace.
{/* You can add a `--preview` flag to interact with a preview namespace instead of a production namespace. */}
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this supposed to be removed?

The browser should simply return the `VALUE` corresponding to the `KEY` you have specified with the `get()` method.
1. Writes a key to your KV namespace using KV's `put()` method.
2. Reads the same key using KV's `get()` method.
3. It checks if the key is null, and returns a `404` response if it is.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
3. It checks if the key is null, and returns a `404` response if it is.
3. Checks if the key is null, and returns a `404` response if it is.

2. Reads the same key using KV's `get()` method.
3. It checks if the key is null, and returns a `404` response if it is.
4. If the key is not null, it returns the value of the key.
5. Uses JavaScript's [`try...catch`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch) exception handling to catch potential errors. When writing or reading from any service, such as Workers KV or external APIs using `fetch()`, you should expect to handle exceptions explicitly.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
5. Uses JavaScript's [`try...catch`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch) exception handling to catch potential errors. When writing or reading from any service, such as Workers KV or external APIs using `fetch()`, you should expect to handle exceptions explicitly.
5. Uses JavaScript's [`try...catch`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/try...catch) exception handling to catch potential errors. When writing or reading from any service, such as Workers KV or external APIs using `fetch()`, you should expect to handle exceptions explicitly.

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.

6 participants