Pages KV Integration
Pages KV storage is a powerful distributed Key-Value storage system provided by EdgeOne.
Overview
KV storage is applicable to dynamic feature enhancement for static websites, lightweight data storage, serverless application support, and data caching. Compared with traditional databases, it is more suitable for read-heavy scenarios as a lightweight storage solution.
Getting Started
If it is your first-time use of Pages KV storage service, we recommend using the template we provide to try. The overall operation steps include three steps: enable the KV storage service, associate the Pages project with the KV space, and use KV storage in the project. The following introduces the related content in detail.
Enabling Pages KV Service
Enter the Pages console, click
KV Storage in the header navigation bar, then click Apply now to start enabling.
To enable the KV storage service, complete the following steps:
1. Fill in application reasons - Describe the usage scenario and target based on your actual business need.
2. Submit application - After completing the application form, click the
Submit button to officially submit for review.3. Wait for approval - The system will notify related staff to evaluate and handle it.
4. Create Namespace
Service activated, click the
Create Namespace option in the console.Assign a name with business significance to the namespace
Click to confirm completion of creation
5. Initialize KV storage
Navigate to the
Data Management sectionClick
Create Record to start configuration of key-value pair dataSet the key name (Key) and value (Value) based on business requirements
Complete all required fields and submit
Note: After KV storage initialization is completed, data read and write operations can be performed via API. It is advisable to plan the key name naming specification and data storage structure in advance.
Creating a Pages Project and Associating KV Storage
1. Deploying a Pages KV Template
On the console
Pages Project webpage, click Create project -> Start from template. In the left sidebar, find Database -> Pages KV, select Pages functions for KV Template

Open the template, click
Create on the deployment page. Deployment usually takes about 20 seconds. Before deployment, if not associated with an online Git, you need to complete Git authorization (supports Github/Gitee).
2. Bind a Namespace to Pages Project
After deployment, click
KV Storage in the left navigation bar, then click Bind Namespace on the page.
In the Bind Namespace window, select the
Namespace created in the KV service applied for earlier, then fill in Variable Name. Variable Name will be used in code to access variables in the Namespace.
3. Implementing KV Operations in Code
For specific use, check the template code in Pages functions for KV, specifically
/functions/visit/index.js. The following is a simple access request example.// Get variableconst visitCount = await my_kv.get('visitCount');let visitCountInt = Number(visitCount);visitCountInt += 1;// Modify variableawait my_kv.put('visitCount', visitCountInt.toString());const res = JSON.stringify({visitCount: visitCountInt,});
Local Development
EdgeOne CLI provides developers with a powerful command line interface tool that can significantly improve your development efficiency and code quality. With this tool, you can:
Perform edge computing operations intuitively and simplify the configuration process
Efficiently debug code: detect and optimize code performance in real time in the local environment
Online data sync: easily import production environment data to the local development environment for true and reliable testing
Precise problem localization: quickly identify and address performance bottlenecks in edge computing
Whether you are an experienced developer or a beginner just exposed to edge computing, EdgeOne CLI can help you build more stable and efficient applications. For more information on advanced functions and best practices, please visit our operation documentation.
More Related Content
Learn about EdgeOne CLI usage: EdgeOne CLI instructions
Learn about KV Storage: KV Storage operation instructions
Learn more about edge function usage: Edge function operation instructions
