4.0.15 ā€¢ Published 2 days ago

basehub v4.0.15

Weekly downloads
-
License
MIT
Repository
github
Last release
2 days ago

basehub šŸŖ„

JavaScript / TypeScript SDK for BaseHub, the first AI-native content hub.

Features:

  • āœØ Infers types from your BaseHub repository... meaning IDE autocompletion works great.
  • šŸŽļø No dependency on graphql... meaning your bundle is more lightweight.
  • šŸŒ Works everywhere fetch is supported... meaning you can use it anywhere.

Install

npm i basehub

Quickstart

1. Set required environment variable:

# .env

BASEHUB_URL="https://basehub.com/<team-slug>/<repo-slug>/graphql?token=<read-token>"

# or disambiguated

BASEHUB_TEAM="<team-slug>"
BASEHUB_REPO="<repo-slug>"
BASEHUB_TOKEN="<read-token>"

šŸ’” Get your read token from the Connect panel: https://basehub.com/<team-slug>/<repo-slug>/connect

2. Generate client:

npx run basehub

ā—ļø Important: make sure you run the generator before your app's build step. A common pattern is to run it in your postinstall script.

3. Use in your app:

This example uses Next.js, but you can use any JavaScript framework.

// app/page.tsx

import { basehub } from "basehub";

const Page = async () => {
  const firstQuery = await basehub().query({
    __typename: true,
  });

  return <pre>{JSON.stringify(firstQuery, null, 2)}</pre>;
};

export default Page;

Choosing another output directory with --output

By default, basehub will generate the SDK inside node_modules/basehub/dist/generated-client. While this is a good default as it allows you to quickly get started, this approach modifies node_modules which, depending on your setup, might result in IDE or build pipeline issues. If this happens, please report the issue!

Additionally, you might want to connect to more than one BaseHub Repository.

To solve this, basehub supports an --output argument that specifies the directory in which the SDK will be generated. You then can use this directory to import generated stuff. For example: running basehub --output .basehub will generate the SDK in a new .basehub directory in the root of your project. You can then import { basehub } from '../<path>/.basehub' and use the SDK normally.

We recommend including the new --output directory to .gitignore, as these generated files are not precisely relevant to Git, but that's up to you and shouldn't affect the SDK's behavior.

About the SDK

The basehub sdk is generated with GenQL (read their docs). Thank you Morse for creating such a great package.

4.0.15

2 days ago

4.0.14

2 days ago

4.0.13

8 days ago

4.0.12

16 days ago

4.0.11

16 days ago

4.0.10

21 days ago

4.0.9

21 days ago

4.0.5

24 days ago

4.0.4

24 days ago

4.0.7

23 days ago

4.0.6

24 days ago

4.0.8

23 days ago

4.0.1

28 days ago

4.0.0

28 days ago

4.0.3

28 days ago

4.0.2

28 days ago

3.1.10

30 days ago

3.2.0

29 days ago

3.2.0-next.0

29 days ago

3.1.9

1 month ago

3.1.8

1 month ago

3.1.7

1 month ago

3.1.6

1 month ago

3.1.5

1 month ago

3.1.3

1 month ago

3.1.2

1 month ago

3.1.1

1 month ago

3.1.0

1 month ago

3.1.4

1 month ago

3.0.8

1 month ago

3.0.7

1 month ago

3.0.6

1 month ago

3.0.5

2 months ago

3.0.5-next.1

2 months ago

3.0.5-next.0

2 months ago

3.0.4

2 months ago

3.0.3

2 months ago

3.0.2

2 months ago

3.0.1

2 months ago

3.0.0

2 months ago

1.4.0-next.5

2 months ago

1.4.0-next.6

2 months ago

1.4.0-next.7

2 months ago

2.0.1

2 months ago

2.0.0

2 months ago

1.4.0-next.1

2 months ago

1.4.0-next.2

2 months ago

1.4.0-next.0

2 months ago

1.4.0-next.3

2 months ago

1.4.0-next.4

2 months ago

1.3.17

3 months ago

1.3.15

3 months ago

1.3.16

3 months ago

1.3.13

3 months ago

1.3.14

3 months ago

1.3.12

3 months ago

1.3.11

3 months ago

1.3.7

3 months ago

1.3.6

3 months ago

1.3.10

3 months ago

1.3.9

3 months ago

1.3.8

3 months ago

1.3.5

3 months ago

1.3.4

3 months ago

1.3.3

4 months ago

1.3.2

4 months ago

1.3.1

4 months ago

1.3.0

4 months ago

1.2.14

5 months ago

1.2.12

5 months ago

1.2.13

5 months ago

1.2.11

5 months ago

1.2.10

5 months ago

1.2.9

6 months ago

1.2.8

6 months ago

1.2.7

6 months ago

1.2.6

6 months ago

1.2.5

6 months ago

1.2.4

6 months ago

1.2.3

6 months ago

1.2.2

6 months ago

1.2.1

7 months ago

1.2.1-next.0

7 months ago

1.2.0

7 months ago

1.1.0

8 months ago

1.0.1

8 months ago

1.0.0

9 months ago

0.0.10

9 months ago

0.0.9

9 months ago

0.0.8

9 months ago

0.0.7

9 months ago

0.0.6

9 months ago

0.0.5

9 months ago

0.0.4

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago