Skip to content

Test new doc - #563

Merged
Leo-rq-yu merged 9 commits into
mainfrom
fix/new-react-pkg
Nov 8, 2025
Merged

Leo-rq-yu merged 9 commits into
mainfrom
fix/new-react-pkg

Conversation

@Leo-rq-yu

@Leo-rq-yu Leo-rq-yu commented Nov 7, 2025 •

Copy link
Copy Markdown
Contributor

Summary

How did you test this change?

Summary by CodeRabbit

  • New Features

    • Added RouteGuard for router-agnostic built-in auth; restored Next.js frontend option and introduced a React Router frontend option.
  • Documentation

    • New React Router authentication guide with components, hooks, examples and advanced flows.
    • Updated React and Next.js docs to use unified authConfig shape and simplified user fields.
  • Chores

    • Build config simplified to default sourcemap and chunking behavior.

@coderabbitai

coderabbitai Bot commented Nov 7, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Reintroduced auth-components-nextjs, added auth-components-react-router, added a new React Router MDX doc, converted React docs to a RouteGuard/router-agnostic flow and { authConfig, isLoaded } shape, updated Next.js docs and User shape, updated instructions listings, and removed explicit sourcemap/manualChunks from Vite config.

Changes

Cohort / File(s) Summary
Docs routing map
backend/src/api/routes/docs.ts
Reintroduced auth-components-nextjs and added auth-components-react-router entries in DOCS_MAP; mapping contents changed, type signature unchanged.
New React Router docs
docs/core-concepts/authentication/ui-components/react-router.mdx
Added MDX documentation for @insforge/react-router covering quick start, provider/config, router integration, UI components, hooks, flows, and advanced usage.
React docs update
docs/core-concepts/authentication/ui-components/react.mdx
Reworked examples from router-wired to router-agnostic using RouteGuard; replaced previous { oauthProviders, emailConfig, isLoaded } references with { authConfig, isLoaded } and updated code samples accordingly.
Next.js docs update
docs/core-concepts/authentication/ui-components/nextjs.mdx
Updated examples to consume { authConfig, isLoaded }, adjusted documented User shape to (id, email, name?, avatarUrl?), and simplified snippet formatting/base URLs.
Instructions doc
docs/insforge-instructions-sdk.md
Replaced auth-components-react mentions with auth-components-react-router / @insforge/react-router, updated quick-start/framework-selection guidance and package listings.
Build config change
auth/vite.config.ts
Removed explicit sourcemap: true and custom rollupOptions.output.manualChunks block; Vite/Rollup defaults now apply.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Files needing extra attention:
    • backend/src/api/routes/docs.ts — verify DOCS_MAP keys/values and any consumers depending on exact keys.
    • docs/core-concepts/.../react.mdx & react-router.mdx — confirm examples (RouteGuard, Protect, usePublicAuthConfig) match actual package exports and runtime shapes.
    • docs/core-concepts/.../nextjs.mdx — validate updated User shape and examples align with live types and SDK exports.
    • auth/vite.config.ts — ensure removing explicit sourcemap/manualChunks doesn't change expected build artifacts in CI or published bundles.

Possibly related PRs

Suggested reviewers

  • tonychang04
  • Fermionic-Lyu

Poem

🐇 I hopped through maps and MDX bright,
RouteGuard ready, hooks in sight,
New router pages, tidy and neat,
Doc carrots queued for every seat,
🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Test new doc' is vague and generic, using non-descriptive language that doesn't clearly convey the main changes in the changeset. Revise the title to specifically describe the primary change, such as 'Add React Router authentication components documentation and update API references' or similar.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/new-react-pkg

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

// UI Components - Framework-specific
'auth-components-nextjs': 'core-concepts/authentication/ui-components/nextjs.mdx',
'auth-components-react': 'core-concepts/authentication/ui-components/react.mdx',
'auth-components-nextjs': 'core-concepts/authentication/ui-components/nextjs.mdx',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is mcp right now needing to read all 3?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, it's good to let MCP read all of them just to make things work.

@Leo-rq-yu
Leo-rq-yu requested a review from tonychang04 November 8, 2025 00:40

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
docs/core-concepts/authentication/ui-components/react-router.mdx (2)

62-65: Minor: Markdown hyphenation for readability.

Lines 62–65 use "sign in" and "sign out" as two words in the bullet-list descriptions. For consistency and readability in parameter documentation, consider using hyphens: "sign-in" and "sign-out".

This is a minor style preference and can be deferred if your documentation guidelines differ.

- `afterSignInUrl` (required): Redirect URL after successful sign in (default: `'/'`)
- `onSignIn` (optional): Custom function to sync token on sign in
- `onSignOut` (optional): Custom function to clear auth state on sign out
+ `afterSignInUrl` (required): Redirect URL after successful sign-in (default: `'/'`)
+ `onSignIn` (optional): Custom function to sync token on sign-in
+ `onSignOut` (optional): Custom function to clear auth state on sign-out

450-453: Minor: Hyphenation for parameter descriptions (optional).

Line 452 describes "Redirect URL after sign out". For consistency, consider "after sign-out" to match parameter naming conventions (e.g., afterSignOutUrl).

- `afterSignOutUrl` - Redirect URL after sign out
+ `afterSignOutUrl` - Redirect URL after sign-out
docs/core-concepts/authentication/ui-components/react.mdx (2)

139-165: Path-based routing approach is workable but has limitations.

The refactored App component now uses window.location.pathname for routing instead of React Router. While this simplifies the example and works for basic use cases, it has drawbacks:

  • No history API integration: Browser back/forward buttons won't work correctly.
  • Manual redirects: Line 158 uses window.location.href, causing full-page reloads instead of smooth client-side navigation.
  • Scalability: This pattern doesn't scale well for apps with many routes.

Consider: Either clarify that this is a simplified example for learning, or recommend a lightweight router library (e.g., TanStack Router, Wouter) as a better alternative for real applications.

You could add a note like:

 #### Step 2: Configure Router with Custom Pages
 
-Set `builtInAuth: false` and provide your page components:
+Set `builtInAuth: false` and provide your page components.
+
+**Note:** The example below uses basic path matching for simplicity. For production apps, consider using a lightweight router library like TanStack Router or Wouter for better navigation and state management.

Or offer an example with a simpler router library as an alternative block.


71-71: Grammar: Use hyphens for compound modifiers.

Lines 71 and 74 use two-word phrases that would benefit from hyphenation:

  • Line 71: "hosted auth pages" → "hosted-auth pages"
  • Line 74: "signin or signup page" → "sign-in or sign-up page"

These are minor style suggestions and can be addressed if your documentation guidelines prefer it.

- `builtInAuth` (optional): By default use InsForge hosted auth pages
+ `builtInAuth` (optional): By default use InsForge hosted-auth pages
- `loadingFallback` (optional): Custom component to display when redirecting to signin or signup page
+ `loadingFallback` (optional): Custom component to display when redirecting to sign-in or sign-up page

Also applies to: 74-74

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3bea961 and 9dbad1d.

📒 Files selected for processing (3)
  • docs/core-concepts/authentication/ui-components/nextjs.mdx (7 hunks)
  • docs/core-concepts/authentication/ui-components/react-router.mdx (1 hunks)
  • docs/core-concepts/authentication/ui-components/react.mdx (11 hunks)
🧰 Additional context used
🧠 Learnings (7)
📚 Learning: 2025-10-15T18:18:47.519Z
Learnt from: CR
Repo: InsForge/InsForge PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-15T18:18:47.519Z
Learning: Applies to frontend/src/**/use[A-Z]*.ts : Hook files must be named usePascalCase.ts (e.g., useAuth.ts)

Applied to files:

  • docs/core-concepts/authentication/ui-components/nextjs.mdx
  • docs/core-concepts/authentication/ui-components/react-router.mdx
📚 Learning: 2025-10-15T18:18:47.519Z
Learnt from: CR
Repo: InsForge/InsForge PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-15T18:18:47.519Z
Learning: Applies to frontend/src/**/*.{tsx,ts} : Use functional React components with hooks exclusively

Applied to files:

  • docs/core-concepts/authentication/ui-components/nextjs.mdx
  • docs/core-concepts/authentication/ui-components/react.mdx
📚 Learning: 2025-11-04T05:18:26.126Z
Learnt from: Fermionic-Lyu
Repo: InsForge/InsForge PR: 553
File: docs/changelog.mdx:6-35
Timestamp: 2025-11-04T05:18:26.126Z
Learning: The InsForge JavaScript SDK repository is named "insforge-sdk-js" and is located at https://github.com/insforge/insforge-sdk-js

Applied to files:

  • docs/core-concepts/authentication/ui-components/nextjs.mdx
  • docs/core-concepts/authentication/ui-components/react.mdx
📚 Learning: 2025-10-15T18:18:47.519Z
Learnt from: CR
Repo: InsForge/InsForge PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-15T18:18:47.519Z
Learning: Applies to backend/src/api/**/*.ts : Implement authentication and error-handling middleware

Applied to files:

  • docs/core-concepts/authentication/ui-components/nextjs.mdx
📚 Learning: 2025-10-15T18:18:47.519Z
Learnt from: CR
Repo: InsForge/InsForge PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-15T18:18:47.519Z
Learning: Applies to frontend/src/**/*.{ts,tsx} : Use React Hook Form for form handling with Zod validation

Applied to files:

  • docs/core-concepts/authentication/ui-components/react.mdx
📚 Learning: 2025-10-15T18:18:47.519Z
Learnt from: CR
Repo: InsForge/InsForge PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-15T18:18:47.519Z
Learning: Applies to frontend/src/**/*.{tsx} : Use lazy loading for code splitting

Applied to files:

  • docs/core-concepts/authentication/ui-components/react.mdx
📚 Learning: 2025-10-15T18:18:47.519Z
Learnt from: CR
Repo: InsForge/InsForge PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-15T18:18:47.519Z
Learning: Applies to frontend/src/**/*.{tsx,ts} : Optimize React component re-renders

Applied to files:

  • docs/core-concepts/authentication/ui-components/react.mdx
🪛 LanguageTool
docs/core-concepts/authentication/ui-components/react.mdx

[grammar] ~71-~71: Use a hyphen to join words.
Context: ...uth(optional): By default use InsForge hosted auth pages -paths` (optional): ...

(QB_NEW_EN_HYPHEN)


[grammar] ~74-~74: Ensure spelling is correct
Context: ...o display when redirecting to signin or signup page ### Step 3: Use Hooks & Component...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

docs/core-concepts/authentication/ui-components/react-router.mdx

[grammar] ~62-~62: Use a hyphen to join words.
Context: ...red): Redirect URL after successful sign in (default: '/') - onSignIn (option...

(QB_NEW_EN_HYPHEN)


[grammar] ~63-~63: Use a hyphen to join words.
Context: ...): Custom function to sync token on sign in - onSignOut (optional): Custom func...

(QB_NEW_EN_HYPHEN)


[grammar] ~64-~64: Use a hyphen to join words.
Context: ...tom function to clear auth state on sign out ### Step 3: Configure Router (Built...

(QB_NEW_EN_HYPHEN)


[grammar] ~452-~452: Use a hyphen to join words.
Context: ...terSignOutUrl- Redirect URL after sign out ###` Complete ...

(QB_NEW_EN_HYPHEN)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: E2E Tests
  • GitHub Check: CI Pre-merge Check
🔇 Additional comments (8)
docs/core-concepts/authentication/ui-components/react-router.mdx (1)

613-632: Example code uses correct new API shape.

The usePublicAuthConfig() example correctly accesses authConfig.oAuthProviders and authConfig?.passwordMinLength, aligning with the updated public API introduced in this PR.

docs/core-concepts/authentication/ui-components/nextjs.mdx (2)

286-288: User object documentation updated consistently.

The useUser() return value now documents user object with optional properties (name?, avatarUrl?), which correctly reflects the updated schema and aligns with safe property access patterns.


298-305: usePublicAuthConfig API shape correctly reflected.

The example correctly demonstrates accessing authConfig.oAuthProviders and authConfig?.passwordMinLength from the new API shape, with appropriate optional chaining for passwordMinLength.

docs/core-concepts/authentication/ui-components/react.mdx (5)

26-26: Dependencies correctly simplified.

Removing react-router-dom from required dependencies aligns with the new RouteGuard-based approach, which no longer requires explicit router setup. The simpler dependency list better reflects the framework-agnostic nature of the package.

Also applies to: 29-29


39-39: RouteGuard introduction simplifies setup.

The new RouteGuard component wrapping App eliminates the need for explicit React Router configuration. This reduces boilerplate and makes the quick-start more accessible. The props documentation (lines 69–74) clearly outlines the available options (builtInAuth, publicRoutes, loadingFallback).

Also applies to: 50-74


93-93: Optional chaining on user property: Intentional safety pattern.

Line 93 uses {user?.email} with optional chaining, whereas the nextjs.mdx example (line 117) uses {user.email} without it. Both patterns are correct depending on context:

  • user?.email is safer if user could be null/undefined (defensive).
  • user.email is fine if you're certain user exists (e.g., inside a <SignedIn> component).

Since line 91 wraps this in <SignedIn>, direct access is safe. Either approach is acceptable; just ensure consistency across documentation if possible.


440-441: JSX comment syntax corrected.

The fix from // Custom logic to {/* Custom logic */} is correct—inline JSX comments must use the {/* */} syntax. Good catch on the prior fix.


561-572: usePublicAuthConfig example correctly updated to new API shape.

The example reflects the updated public API: authConfig returned as an object containing oAuthProviders and passwordMinLength, with proper optional chaining on the latter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants