@katla.app/sdk 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +119 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,119 @@
1
+ # @katla.app/sdk
2
+
3
+ TypeScript SDK for building custom cookie consent flows with Katla.
4
+
5
+ Get started:
6
+ - Create your account and site at [katla.app](https://katla.app)
7
+ - Read full guides at [docs.katla.app](https://docs.katla.app)
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install @katla.app/sdk
13
+ ```
14
+
15
+ Requirements:
16
+ - Node.js 24+
17
+ - React 18+ or 19+ (only for React/Next integrations)
18
+
19
+ ## Basic usage
20
+
21
+ ```ts
22
+ import { createKatlaClient } from '@katla.app/sdk';
23
+
24
+ const client = createKatlaClient({
25
+ siteId: 'your-site-id',
26
+ // baseUrl: 'https://dist.katla.app', // optional override
27
+ });
28
+
29
+ const cookies = await client.getCookies();
30
+ const manifest = await client.getManifest();
31
+
32
+ const unsubscribe = client.onConsentChange((consent) => {
33
+ console.log('Updated consent:', consent);
34
+ });
35
+
36
+ await client.injectGuard();
37
+
38
+ unsubscribe();
39
+ ```
40
+
41
+ ## React usage
42
+
43
+ ```tsx
44
+ import {
45
+ KatlaProvider,
46
+ KatlaGuard,
47
+ ConsentBridge,
48
+ useKatlaCookies,
49
+ } from '@katla.app/sdk/react';
50
+
51
+ function CookieList() {
52
+ const { cookies, loading, error } = useKatlaCookies();
53
+
54
+ if (loading) return <p>Loading...</p>;
55
+ if (error) return <p>Failed: {error.message}</p>;
56
+ if (!cookies) return null;
57
+
58
+ return <pre>{JSON.stringify(cookies.cookies, null, 2)}</pre>;
59
+ }
60
+
61
+ export function App() {
62
+ return (
63
+ <KatlaProvider siteId="your-site-id">
64
+ <KatlaGuard />
65
+ <ConsentBridge />
66
+ <CookieList />
67
+ </KatlaProvider>
68
+ );
69
+ }
70
+ ```
71
+
72
+ ## Next.js usage
73
+
74
+ Client provider:
75
+
76
+ ```tsx
77
+ import { KatlaNextProvider } from '@katla.app/sdk/next';
78
+
79
+ export default function Providers({ children }: { children: React.ReactNode }) {
80
+ return <KatlaNextProvider siteId="your-site-id">{children}</KatlaNextProvider>;
81
+ }
82
+ ```
83
+
84
+ Server-side cached fetch:
85
+
86
+ ```tsx
87
+ import { getCachedCookies } from '@katla.app/sdk/next/server';
88
+
89
+ export default async function Page() {
90
+ const data = await getCachedCookies({ siteId: 'your-site-id' });
91
+ return <pre>{JSON.stringify(data.cookies, null, 2)}</pre>;
92
+ }
93
+ ```
94
+
95
+ ## Static cookie data (build-time)
96
+
97
+ CLI:
98
+
99
+ ```bash
100
+ katla pull <site-id> -o ./src/data/katla-cookies.json
101
+ ```
102
+
103
+ Programmatic:
104
+
105
+ ```ts
106
+ import { fetchStaticCookies } from '@katla.app/sdk/static';
107
+
108
+ await fetchStaticCookies({
109
+ siteId: 'your-site-id',
110
+ outputPath: './src/data/katla-cookies.json',
111
+ });
112
+ ```
113
+
114
+ Use the generated JSON as `initialCookies` in `KatlaProvider`/`KatlaNextProvider` to skip runtime cookie fetches.
115
+
116
+ ## Documentation
117
+
118
+ - Product onboarding: [katla.app](https://katla.app)
119
+ - Developer docs: [docs.katla.app](https://docs.katla.app)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@katla.app/sdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {