@base316/react 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Thinkfleet AI, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # @base316/react
2
+
3
+ Drop-in React components for [Base316](https://base316.com) — sign-in, sign-up,
4
+ profile, pricing and billing, rendered inside your own application rather than
5
+ on a page your users are sent away to.
6
+
7
+ ```bash
8
+ npm install @base316/react @base316/sdk
9
+ ```
10
+
11
+ ## Wrap your app once
12
+
13
+ ```tsx
14
+ import { Base316Provider } from "@base316/react";
15
+
16
+ export default function App({ children }) {
17
+ return (
18
+ <Base316Provider publishableKey={process.env.NEXT_PUBLIC_BASE316_KEY}>
19
+ {children}
20
+ </Base316Provider>
21
+ );
22
+ }
23
+ ```
24
+
25
+ The provider holds one client and the signed-in user's session, and fetches the
26
+ branding you configured in the Base316 dashboard — so what you set there is what
27
+ these components look like here. No colours to keep in step in two places.
28
+
29
+ ## Sign in, in your own page
30
+
31
+ ```tsx
32
+ import { SignIn } from "@base316/react";
33
+
34
+ export default function LoginPage() {
35
+ return <SignIn onSignedIn={() => router.push("/app")} />;
36
+ }
37
+ ```
38
+
39
+ That is the whole integration. No redirect, no popup, no button that sends
40
+ somebody to another domain and back. Two-factor prompts are handled inside the
41
+ component when the account has it enrolled.
42
+
43
+ If you would rather not render sign-in at all, Base316 also hosts the pages —
44
+ point your users at the link in the dashboard and they come back signed in.
45
+
46
+ ## The rest
47
+
48
+ ```tsx
49
+ import {
50
+ UserProfile, // email, password, sessions, two-factor
51
+ PricingTable, // your plans, with a checkout button
52
+ SubscriptionManager, // what they are on, and how to change it
53
+ Invoices, // what they have been billed
54
+ Branding, // your logo and name, as configured
55
+ } from "@base316/react";
56
+ ```
57
+
58
+ ## Styling
59
+
60
+ Three ways, from least to most invasive. Use the first that works.
61
+
62
+ **1. The dashboard.** Whatever you set under *Sign-in pages* — brand colour,
63
+ background, logo — arrives here automatically.
64
+
65
+ **2. `appearance` tokens.** No CSS to write:
66
+
67
+ ```tsx
68
+ <Base316Provider
69
+ publishableKey={key}
70
+ appearance={{ colorPrimary: "#16a34a", borderRadius: "999px" }}
71
+ >
72
+ ```
73
+
74
+ **3. Your own CSS**, targeting the `b316-*` class names, or a `className` on any
75
+ component to hand it your utility classes.
76
+
77
+ Every colour, radius and font is behind a `--b316-*` custom property. Nothing
78
+ inherits your application's styles automatically — silently absorbing whatever
79
+ `body { font }` and `button { }` rules happen to exist produces components that
80
+ look broken in ways neither side can predict.
81
+
82
+ ## Reading the session
83
+
84
+ ```tsx
85
+ import { useSession } from "@base316/react";
86
+
87
+ function Greeting() {
88
+ const { session, loading } = useSession();
89
+
90
+ if (loading) return null;
91
+ return session ? <p>Hello {session.user.email}</p> : <a href="/login">Sign in</a>;
92
+ }
93
+ ```
94
+
95
+ `loading` matters: rendering the signed-out branch first and then swapping makes
96
+ every page flash a sign-in link at people who are already signed in.