@squadbase/nextjs 0.1.0-beta.0 → 0.2.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.
Files changed (2) hide show
  1. package/README.md +21 -21
  2. 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
- // In your Next.js server component or API route
23
- const client = createNextjsServerClient({
24
- projectId: "your-project-id",
25
- });
26
-
27
- // Get the current authenticated user
28
- const user = await client.getUser();
29
- console.log(user);
30
- // {
31
- // username: string,
32
- // email: string,
33
- // firstName: string,
34
- // lastName: string,
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
- ### Local Development
40
+ ### Outside Squadbase Environments
41
41
 
42
- For local development, you can provide a mock user:
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: NextjsServerClientOptions)`
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` (string): Your Squadbase project ID
67
- - `mockUser` (optional): Mock user object for local development
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-beta.0",
3
+ "version": "0.2.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-beta.0"
28
+ "@squadbase/server": "0.2.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/node": "^22.14.1",