Connect Strapi with Astra DB using a hook

Strapi is an open-source headless CMS that gives developers the freedom to choose their favorite tools and frameworks and allows editors to manage and distribute their content using their application’s admin panel. Based on a plugin system, its admin panel and API are extensible. Every part is customizable to match any use case. Strapi also has a built-in user system to manage what the administrators and end users can access.


  1. Install Strapi locally:

    npx create-strapi-app my-project

    You can view your Strapi project as it is hosted locally at http://localhost:1337/admin.

  2. Install the Strapi hook:

    npm i strapi-hook-astra
  3. Activate the hook by adding the following to `./config/hook.js of the sample Strapi Project:

    module.exports = {
        settings: {
            astra: {
                enabled: true,
                token: 'REPLACE_ME',
                databaseId: 'REPLACE_ME',
                databaseRegion: 'REPLACE_ME',
                keyspace: 'REPLACE_ME',
                collection: 'REPLACE_ME'
    • token: Generate a token from Astra DB.

    • databaseId: Enter your Astra DB database ID from your database URL.

    • databaseRegion: Enter your Astra DB database region

    • keyspace: Enter your Astra DB keyspace name.

    • collection: Enter your Astra DB collection name.

  4. Create a document:;
    Parameter Type Explanation Values



    Create a document

    var dataString = '{ "name": "John", "last_name": "Doe" }'

  5. Get document by ID:;
    Parameter Type Explanation Values



    Get document by documentId

    var documentId = "your_document_id"

  6. Get document by path:;
  7. Search a collection:,pagesize);
    Parameter Type Explanation Values



    Search collection via query

    var query = {"name": { "$eq": "John" }}



    Number of documents to fetch

    int page_size = 3

For more, see the Strapi documentation.