Skip to content

Stage #121

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

Merged
merged 24 commits into from
Jul 22, 2025
Merged

Stage #121

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ab10858
feat(accessTokens): first draft
danielebriggi Apr 24, 2025
e566c16
fix(tokens): minor changes
danielebriggi May 22, 2025
4c64125
feat(accessTokens): explain the access tokens example
danielebriggi May 26, 2025
d3d7a9c
Merge branch 'introduce-access-tokens' into stage
danielebriggi May 26, 2025
1e5e1f2
fix(accessTokens): missing nav reference
danielebriggi May 26, 2025
821dcc1
Merge branch 'introduce-access-tokens' into stage
danielebriggi May 26, 2025
fd5da60
fix(accessTokens): typos
danielebriggi May 26, 2025
fe400ef
Merge branch 'introduce-access-tokens' into stage
danielebriggi May 26, 2025
ed7b1f4
fix(accessTokens): typos
danielebriggi May 26, 2025
88a5edb
Merge branch 'introduce-access-tokens' into stage
danielebriggi May 26, 2025
591fab0
add new docs page for RLS
andinux Jul 14, 2025
73624bd
Merge pull request #118 from sqlitecloud/platform-rls
TizianoT Jul 14, 2025
65460dd
removed readme from build
TizianoT Jul 14, 2025
a2e991b
trigger build
TizianoT Jul 14, 2025
38ea40a
trigger build
TizianoT Jul 14, 2025
7d41d13
Update rls.mdx
andinux Jul 14, 2025
172d78d
add offsync doc
andinux Jul 16, 2025
5a4dcac
add a link to offsync doc
andinux Jul 16, 2025
2a1ad8e
fix rls link
andinux Jul 16, 2025
d0ac8d6
Merge pull request #119 from sqlitecloud/feat/add-offsync-doc
andinux Jul 16, 2025
6c7ee4f
fix: use the correct casing for OffSync
andinux Jul 16, 2025
188e71a
Update search.yml to use docsearch-action@v6
andinux Jul 16, 2025
5941268
Merge pull request #120 from sqlitecloud/andinux-patch-1-1
andinux Jul 16, 2025
6e6c458
Updated documentation
marcobambini Jul 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/search.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: sqlitecloud/docsearch-action@v5
- uses: sqlitecloud/docsearch-action@v6
with:
project-string: ${{ secrets.PROJECT_STRING }}
base-url: ${{ vars.BASE_URL }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
121 changes: 45 additions & 76 deletions sqlite-cloud/_nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,88 +2,56 @@ import type { SidebarNavStruct } from "@docs-website/types/sidebar-navigation";

const sidebarNav: SidebarNavStruct = [
{ title: "", type: "primary" },
{
title: "Introduction",
type: "secondary",
icon: "docs-star",
},
// ### AI ###
{ title: "AI", type: "secondary", icon: "docs-star",},
{ title: "Overview", filePath: "ai-overview", type: "inner", level: 0 },
{ title: "SQLite-AI", filePath: "sqlite-ai", type: "inner", level: 0 },
{ title: "SQLite-JS", filePath: "sqlite-js", type: "inner", level: 0 },
{ title: "SQLite-Sync", filePath: "sqlite-sync", type: "inner", level: 0 },
{ title: "SQLite-Vector", filePath: "sqlite-vector", type: "inner", level: 0 },
{ title: "MCP (Model Context Protocol)", filePath: "mcp-server", type: "inner", level: 0 },

// ### CLOUD ###
{ title: "Cloud", type: "secondary", icon: "docs-star",},
{ title: "Overview", filePath: "overview", type: "inner", level: 0 },
{ title: "Scaling", filePath: "architecture", type: "inner", level: 0 },
{ title: "Getting Started", type: "inner", level: 0 },
{ title: "Connecting", filePath: "connect-cluster", type: "inner", level: 1 },
{
title: "Creating a database",
filePath: "create-database",
type: "inner",
level: 1,
},
{ title: "Writing data", filePath: "write-data", type: "inner", level: 1 },
{ title: "Connecting", filePath: "connect-cluster", type: "inner", level: 1 },
{ title: "Creating a database", filePath: "create-database", type: "inner", level: 1 },
{ title: "Writing data", filePath: "write-data", type: "inner", level: 1 },
{ title: "Quick Start Guides", type: "inner", level: 0 },
{ title: "CDN", filePath: "quick-start-cdn", type: "inner", level: 1 },
{ title: "Node.js", filePath: "quick-start-node", type: "inner", level: 1 },
{ title: "React", filePath: "quick-start-react", type: "inner", level: 1 },
{
title: "React Native",
filePath: "quick-start-react-native",
type: "inner",
level: 1,
},
{
title: "Apollo / GraphQL",
filePath: "quick-start-apollo-graphql",
type: "inner",
level: 1,
},
{ title: "Next.js", filePath: "quick-start-next", type: "inner", level: 1 },
{ title: "Django", filePath: "quick-start-django", type: "inner", level: 1 },
{ title: "Flask", filePath: "quick-start-flask", type: "inner", level: 1 },
{
title: "SQLAlchemy",
filePath: "quick-start-sqlalchemy-orm",
type: "inner",
level: 1,
},
{
title: "Streamlit",
filePath: "quick-start-streamlit",
type: "inner",
level: 1,
},
{
title: "PHP / Laravel",
filePath: "quick-start-php-laravel",
type: "inner",
level: 1,
},
{ title: "Gin", filePath: "quick-start-gin", type: "inner", level: 1 },
{ title: "Tutorials", type: "inner", level: 0 },
{ title: "Geopoly", filePath: "tutorial-geopoly", type: "inner", level: 1 },
{ title: "Integrations", type: "inner", level: 0 },
{ title: "Knex.js", filePath: "knex-integration", type: "inner", level: 1 },
{ title: "CDN", filePath: "quick-start-cdn", type: "inner", level: 1 },
{ title: "Node.js", filePath: "quick-start-node", type: "inner", level: 1 },
{ title: "React", filePath: "quick-start-react", type: "inner", level: 1 },
{ title: "React Native", filePath: "quick-start-react-native", type: "inner", level: 1 },
{ title: "Apollo / GraphQL", filePath: "quick-start-apollo-graphql", type: "inner", level: 1 },
{ title: "Next.js", filePath: "quick-start-next", type: "inner", level: 1 },
{ title: "Django", filePath: "quick-start-django", type: "inner", level: 1 },
{ title: "Flask", filePath: "quick-start-flask", type: "inner", level: 1 },
{ title: "SQLAlchemy", filePath: "quick-start-sqlalchemy-orm", type: "inner", level: 1 },
{ title: "Streamlit", filePath: "quick-start-streamlit", type: "inner", level: 1 },
{ title: "PHP / Laravel", filePath: "quick-start-php-laravel", type: "inner", level: 1 },
{ title: "Gin", filePath: "quick-start-gin", type: "inner", level: 1 },
{ title: "Knex.js", filePath: "quick-start-knex", type: "inner", level: 1 },

// ### PLATFORM ###
{ title: "Platform", type: "secondary", icon: "docs-plat" },
{
title: "Edge Functions",
filePath: "edge-functions",
type: "inner",
level: 0,
},
{ title: "Webhooks", filePath: "webhooks", type: "inner", level: 0 },
{ title: "Pub/Sub", filePath: "pub-sub", type: "inner", level: 0 },
{ title: "Vector", filePath: "vector", type: "inner", level: 0 },
{ title: "Scaling", type: "inner", filePath: "architecture", level: 0 },
{
title: "Security and Access Control",
filePath: "security",
type: "inner",
level: 0,
},
{ title: "Backups", filePath: "backups", type: "inner", level: 0 },
{ title: "Query Analyzer", filePath: "analyzer", type: "inner", level: 0 },
{ title: "Extensions", filePath: "extensions", type: "inner", level: 0 },
{ title: "Weblite", filePath: "weblite", type: "inner", level: 0 },
{ title: "AI - Model Context Protocol (MCP)", filePath: "mcp-server", type: "inner", level: 0 },
{ title: "Edge Functions", filePath: "edge-functions", type: "inner", level: 0 },
{ title: "Webhooks", filePath: "webhooks", type: "inner", level: 0 },
{ title: "Pub/Sub", filePath: "pub-sub", type: "inner", level: 0 },
//{ title: "Vector", filePath: "vector", type: "inner", level: 0 },
{ title: "Users and Roles", filePath: "security", type: "inner", level: 0 },
{ title: "API Keys", filePath: "apikey", type: "inner", level: 0 },
{ title: "Row-Level Security", filePath: "rls", type: "inner", level: 0},
{ title: "OffSync", filePath: "offsync", type: "inner", level: 0 },
{ title: "Access Tokens", filePath: "access-tokens", type: "inner", level: 0 },
{ title: "Backups", filePath: "backups", type: "inner", level: 0 },
{ title: "Query Analyzer", filePath: "analyzer", type: "inner", level: 0 },
{ title: "Extensions", filePath: "extensions", type: "inner", level: 0 },
{ title: "Weblite (REST API)", filePath: "weblite", type: "inner", level: 0 },

{ title: "SDKs", type: "secondary", icon: "docs-sdk" },
// ### CLOUD SDK ###
{ title: "Cloud SDK", type: "secondary", icon: "docs-sdk" },
{ title: "C/C++", type: "inner", level: 0 },
{
title: "Introduction",
Expand Down Expand Up @@ -565,6 +533,7 @@ const sidebarNav: SidebarNavStruct = [
level: 1,
},

// ### REFERENCE ###
{ title: "Reference", type: "secondary", icon: "docs-ref" },
{ title: "Server-side Commands", type: "inner", level: 0 },
{
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions sqlite-cloud/platform/_wip-index-with-card.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import IndexPage from "@docs-website-components/Docs/IndexPage.astro"

export const introduction = "SQLite Cloud is a distributed relational database system built on top of the SQLite database engine. It has been specifically designed from the ground up to ensure the strong consistency of your data across all nodes in a cluster while simultaneously managing the technical aspects of scaling, security, and data distribution."



export const sections = [
{
icon: "puzzle",
Expand Down
81 changes: 81 additions & 0 deletions sqlite-cloud/platform/access-tokens.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
title: Access Tokens
description: Grant to your users, devices, tenant, access to SQLite Cloud database and services.
category: platform
status: publish
slug: access-tokens
---

Access Tokens let backend systems securely grant users, devices, tenants, etc. access to SQLite Cloud database and services (SQLite Sync, Weblite, etc.). These endpoints enable full token lifecycle management: creation, inspection, validation, update, and revocation. All endpoints require authentication. Use an **API Key** or an **Access Token** via the `Authorization` header.

The API Documentation for the Access Tokens API can be found in the **Weblite** section in the [Dashboard](https://dashboard.sqlitecloud.io).

---

## Example Using SQLite Cloud Access Tokens with Google Login

In the repository on GitHub [sqlitecloud/examples](https://github.com/sqlitecloud/examples), we created a simple app to demonstrate how to generate and use Access Tokens.

We’ll log in with Google, grab a token, and use it to interact with SQLite Cloud Weblite APIs. Here’s how it works.

In the snippet below, we handle the Google Login callback when the user has completed the login on Google. Here, you can exchange the `code` with the Google Access Token and then decide what to do with it as needed.

```typescript
if (pathname === "/auth/callback") {
const q = query;
if (q.state !== STATE || !q.code) {
return send(res, 400, "Invalid state or missing code");
}

try {
// Exchange code for tokens
// Store the Google Token in the database
const googleToken = await getGoogleTokens(q.code as string);
...
```

Now we have authenticated the user, we are ready to request SQLite Cloud to create a new SQLite Cloud Access Token assigned to this user.

```typescript
async function getSQLiteCloudToken(userId: string) {
const payload = {
name: "test-user-token", // A name for the token, can be anything you want
userId,
expiresAt: new Date(Date.now() + 1000 * 60 * 60 * 24).toISOString(), // expires in 24 hours
};

const res = await fetch("https://<your-project-url>/v2/tokens", {
method: "POST",
headers: {
Authorization: `Bearer ${SQLITE_CLOUD_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});
if (!res.ok) {
throw new Error(`Failed to create SQLite Cloud token: ${res.statusText}`);
}

return res.json();
}
```

In the response JSON, the `data.token` field contains the Access Token.

Finally, the user is authorized to securely access SQLite Cloud services like the Weblite API to perform a query on the database:

```typescript
const res = await fetch("https://<your-project-url>/v2/weblite/sql", {
method: "POST",
headers: {
Authorization: "Bearer " + sqliteCloudToken,
"Content-Type": "application/json",
},
body: JSON.stringify({
sql: "USE DATABASE chinook.sqlite;SELECT * FROM artists LIMIT 10;",
}),
});
...
```

The result depends on the [Row Level Security](https://) you enabled for the tables.
20 changes: 20 additions & 0 deletions sqlite-cloud/platform/apikey.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: Security and Access Control
description: SQLite Cloud provides secure access to resources through role-based authorization, which ensures user isolation and enhances security and manageability.
category: platform
status: publish
slug: apikey
---

## API KEYs

API KEYs can be used as an alternative authentication mechanism.
Authentication through API keys ensures the same privileges as the user to which they are associated.
API KEYs are recommended for all server-to-server authentication cases and are necessary for using the REST APIs and the SDKs that uses the WebSocket APIs.

To create an API key for a user, click on the **Create API KEY** button.

![Dashboard Create APIKEY](@docs-website-assets/introduction/dashboard_create_apikey.png)

The resulting table will display all the API keys associated with each user, along with their name and restrictions.
![Dashboard List APIKEY](@docs-website-assets/introduction/dashboard_list_apikey.png)
9 changes: 6 additions & 3 deletions sqlite-cloud/platform/extensions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ status: publish
slug: extensions
---

SQLite Cloud comes with the following pre-installed SQLite extensions. These extensions are available for use in your SQLite Cloud databases.
SQLite Cloud comes with the following pre-installed SQLite extensions.
These extensions are available for use in your SQLite Cloud databases.

## Extensions
- **[SQLite-Vector](sqlite-vector)**: High performance vector storage extension for similarity search.
- **[SQLite-Sync](sqlite-sync)**: Local-first extension for true local-first data synchronization for your applications.
- **[SQLite-JS](sqlite-js)**: Enables JavaScript integration in SQLite for executing server-side logic.
- **[Full-text Search 5](https://www.sqlite.org/fts5.html)**: Full-text search engine that allows you to search for text in a database.
- **[JSON1](https://www.sqlite.org/json1.html)**: Allows you to easily store, query, and manipulate JSON data.
- **[Math](https://www.sqlite.org/lang_mathfunc.html)**: Mathematical functions.
- **[RTree](https://www.sqlite.org/rtree.html)**: R-Tree index for storing and querying spatial data.
- **[Geopoly](https://www.sqlite.org/geopoly.html)**: Functions for working with geospatial data.
- **[sqlite-vec](/docs/vector)**: Vector storage extension for similarity search.
- **[Geopoly](https://www.sqlite.org/geopoly.html)**: A set of functions for working with geospatial data. For a complete guide, see the [comprehensive tutorial here](tutorial-geopoly).

In the future, we plan to allow users to install their own extensions. If you have a specific extension you would like to use, please let us know by [adding to this issue](https://github.com/sqlitecloud/docs/issues/34).
42 changes: 42 additions & 0 deletions sqlite-cloud/platform/offsync.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: OffSync
description: Enable local-first applications with automatic data synchronization between edge devices and SQLite Cloud.
category: platform
status: publish
slug: offsync
---

import Callout from "@commons-components/Information/Callout.astro";

OffSync is a powerful SQLite Cloud feature that enables true **local-first** data synchronization for your applications. Powered by the [SQLite Sync](https://github.com/sqliteai/sqlite-sync) extension, it allows you to build robust, offline-capable applications where data is stored and processed on edge devices and seamlessly synchronized with a central SQLite Cloud database.

This architecture is ideal for mobile apps, IoT devices, and any application requiring high availability and low latency, even with intermittent network connectivity. By leveraging Conflict-free Replicated Data Types (CRDTs), OffSync ensures that changes made offline are merged automatically and without conflicts when the device reconnects.

## How It Works

OffSync extends standard SQLite tables with built-in support for offline work and automatic synchronization. This allows multiple devices to operate independently and then seamlessly merge their changes.

- **Offline-First by Design**: Applications work seamlessly even when devices are offline. Changes are queued locally and synced automatically when connectivity is restored.
- **CRDT-Based Conflict Resolution**: Merges updates deterministically and efficiently, ensuring eventual consistency across all replicas without complex merge logic.
- **Seamless Integration**: The sync layer is tightly integrated with SQLite Cloud, enabling secure data sharing across devices, users, and platforms.

When combined with [Row-Level Security (RLS)](/docs/rls), OffSync allows you to build secure, multi-tenant applications where each user's data is safely isolated, both on the edge and in the cloud.

## Configuring OffSync

You can enable and manage OffSync for your databases directly from the SQLite Cloud dashboard.

1. **Navigate to the Databases Page**: From the main dashboard, go to the "Databases" page.
2. **Select the Offsync Column**: In the list of your databases, click on the button in the "Offsync" column for the desired database.

![Dashboard Databases Page](@docs-website-assets/introduction/offsync-1.png)

3. **Enable Tables for Synchronization**: On the Offsync settings page, you will see a list of all tables in your database. Toggle the switch next to each table you want to enable for synchronization.

![Dashboard Offsync Settings Page](@docs-website-assets/introduction/offsync-2.png)

<Callout type="note" title="Matching Schemas and Tables">
For OffSync to work correctly, the list of tables configured for synchronization—and their corresponding schemas—must be identical in both your local SQLite database and your SQLite Cloud database.
</Callout>

Once enabled, any changes made to the selected tables via the SQLite Sync extension will be automatically synchronized with your SQLite Cloud database.
Loading