@resultdev/sdk 0.1.0

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.
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # @resultdev/sdk
2
+
3
+ The SDK for apps built on Result Backend — authentication, database, file
4
+ storage, serverless functions and realtime, one client.
5
+
6
+ ```bash
7
+ npm install @resultdev/sdk
8
+ ```
9
+
10
+ ```ts
11
+ import { createClient } from "@resultdev/sdk";
12
+
13
+ export const backend = createClient({
14
+ baseUrl: process.env.NEXT_PUBLIC_BACKEND_URL!,
15
+ anonKey: process.env.NEXT_PUBLIC_BACKEND_ANON_KEY!,
16
+ });
17
+ ```
18
+
19
+ ## Database
20
+
21
+ ```ts
22
+ const { data, error } = await backend.database
23
+ .from("todos")
24
+ .select()
25
+ .order("created_at", { ascending: false });
26
+
27
+ await backend.database.from("todos").insert([{ title: "Hello" }]);
28
+ await backend.database.from("todos").update({ done: true }).eq("id", id);
29
+ await backend.database.from("todos").delete().eq("id", id);
30
+ ```
31
+
32
+ ## Authentication
33
+
34
+ ```ts
35
+ await backend.auth.signUp({ email, password, name });
36
+ await backend.auth.signInWithPassword({ email, password });
37
+ const { data } = await backend.auth.getCurrentUser();
38
+ await backend.auth.signOut();
39
+ ```
40
+
41
+ Once signed in, every database/storage/function call carries the user's
42
+ session automatically — row-level-secured tables just work.
43
+
44
+ ## Storage
45
+
46
+ ```ts
47
+ const { data } = await backend.storage.from("uploads").uploadAuto(file);
48
+ ```
49
+
50
+ ## Functions & realtime
51
+
52
+ ```ts
53
+ await backend.functions.invoke("my-function", { method: "POST", body });
54
+ backend.realtime.subscribe("room:1", (message) => console.log(message));
55
+ ```
56
+
57
+ ## Server-side (Next.js SSR)
58
+
59
+ ```ts
60
+ import { createServerClient } from "@resultdev/sdk/ssr";
61
+ ```
62
+
63
+ Admin operations (schema changes, service-level reads) use your app's admin
64
+ key server-side — see your app's page in the Result dashboard for the
65
+ credentials and the full agent prompt.