@squadbase/nextjs 0.1.0 → 0.2.1-beta.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 +21 -21
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -16,30 +16,30 @@ pnpm add @squadbase/nextjs
|
|
|
16
16
|
|
|
17
17
|
### User Session
|
|
18
18
|
|
|
19
|
+
User info is automatically available in apps deployed to Squadbase or running in Squadbase Editor.
|
|
20
|
+
|
|
19
21
|
```typescript
|
|
22
|
+
// app/api/user/route.ts
|
|
20
23
|
import { createNextjsServerClient } from "@squadbase/nextjs";
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
const client = createNextjsServerClient(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// iconUrl: string | null,
|
|
36
|
-
// roles: string[]
|
|
37
|
-
// }
|
|
25
|
+
export async function GET() {
|
|
26
|
+
const client = createNextjsServerClient();
|
|
27
|
+
const user = await client.getUser();
|
|
28
|
+
// {
|
|
29
|
+
// username: string,
|
|
30
|
+
// email: string,
|
|
31
|
+
// firstName: string,
|
|
32
|
+
// lastName: string,
|
|
33
|
+
// iconUrl: string | null,
|
|
34
|
+
// roles: string[]
|
|
35
|
+
// }
|
|
36
|
+
return Response.json(user);
|
|
37
|
+
}
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
###
|
|
40
|
+
### Outside Squadbase Environments
|
|
41
41
|
|
|
42
|
-
For local development, you
|
|
42
|
+
For use outside Squadbase environments (e.g., local development), you must set the `projectId` and `mockUser` options. These settings are not needed in Squadbase Editor or deployed environments.
|
|
43
43
|
|
|
44
44
|
```typescript
|
|
45
45
|
const client = createNextjsServerClient({
|
|
@@ -57,14 +57,14 @@ const client = createNextjsServerClient({
|
|
|
57
57
|
|
|
58
58
|
## API Reference
|
|
59
59
|
|
|
60
|
-
### `createNextjsServerClient(options
|
|
60
|
+
### `createNextjsServerClient(options?: NextjsServerClientOptions)`
|
|
61
61
|
|
|
62
62
|
Creates a new Next.js server client instance. This is a wrapper around `createServerClient` that automatically handles cookie management using Next.js's `cookies()` API.
|
|
63
63
|
|
|
64
64
|
#### Options
|
|
65
65
|
|
|
66
|
-
- `projectId` (
|
|
67
|
-
- `mockUser` (optional): Mock user object for
|
|
66
|
+
- `projectId` (optional): Your Squadbase project ID. Required outside Squadbase environments.
|
|
67
|
+
- `mockUser` (optional): Mock user object for use outside Squadbase environments
|
|
68
68
|
|
|
69
69
|
### `ServerClient`
|
|
70
70
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squadbase/nextjs",
|
|
3
|
-
"version": "0.1.0",
|
|
3
|
+
"version": "0.2.1-beta.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"author": "Squadbase",
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@squadbase/server": "0.1.0"
|
|
28
|
+
"@squadbase/server": "0.2.1-beta.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^22.14.1",
|