Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

chore(core): update createRivetKit to accept a client options#1392

Closed
NathanFlurry wants to merge 1 commit intomainfrom
10-15-chore_core_update_createrivetkit_to_accept_a_client_options
Closed

chore(core): update createRivetKit to accept a client options#1392
NathanFlurry wants to merge 1 commit intomainfrom
10-15-chore_core_update_createrivetkit_to_accept_a_client_options

Conversation

@NathanFlurry
Copy link
Member

No description provided.

@vercel
Copy link

vercel bot commented Oct 15, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
rivetkit-serverless Ready Ready Preview Comment Oct 15, 2025 8:48am

@claude
Copy link

claude bot commented Oct 15, 2025

Claude finished @NathanFlurry's task —— View job


Code Review Complete ✅

I've thoroughly analyzed this PR. Here's my comprehensive review:

Review Checklist:

  • Analyze core changes to createRivetKit function
  • Review client options implementation
  • Check example file updates for consistency
  • Assess backward compatibility
  • Look for potential security concerns
  • Evaluate performance implications
  • Check for test coverage needs

Summary

This PR refactors the createRivetKit API to accept client input parameters directly instead of requiring a pre-created client, simplifying the developer experience.

Positive Aspects

  1. Improved Developer Experience: The new API is more intuitive - developers can pass client options directly instead of manually creating a client first
  2. Clean API Design: The change maintains the same functionality while reducing boilerplate code
  3. Consistent Implementation: All examples were properly updated to use the new API consistently
  4. Good Backward Compatibility: The old API is preserved via createRivetKitWithClient

🔍 Code Quality & Best Practices

packages/react/src/mod.ts:17-25

Excellent: The implementation correctly wraps createClient and delegates to createRivetKitWithClient, maintaining clean separation of concerns.

export function createRivetKit<Registry extends AnyActorRegistry>(
	clientInput: Parameters<typeof createClient>[0],
	opts: CreateRivetKitOptions<Registry> = {},
) {
	return createRivetKitWithClient<Registry>(
		createClient<Registry>(clientInput),
		opts,
	);
}

Example Consistency

Good: All examples consistently updated from:

// Before
const client = createClient("http://localhost:8080");
const { useActor } = createRivetKit(client);

// After  
const { useActor } = createRivetKit<typeof registry>("http://localhost:8080");

🚀 Performance Considerations

Neutral Impact: No performance concerns identified. The change simply moves client creation inside the function rather than requiring it externally.

🔒 Security Assessment

No Issues: The change doesn't introduce new security vectors. Client configuration still goes through the same validation in ClientConfigSchema.

🧪 Test Coverage

Needs Attention:

  • No new tests were added for the updated API
  • Existing tests in examples/ai-agent/tests/ai-agent.test.ts still use the old setupTest pattern and may need updates
  • Consider adding tests that verify both the new createRivetKit and backward-compatible createRivetKitWithClient APIs

🔄 Backward Compatibility

Excellent: The old API is preserved via createRivetKitWithClient, allowing gradual migration.

⚠️ Minor Issues

  1. examples/next-js/src/lib/rivet-client.ts deletion: This file was removed but it's unclear if any other parts of the codebase imported from it. Should verify no broken imports exist.

  2. Type Safety: The use of Parameters<typeof createClient>[0] is clever but could be more explicit for better type documentation.

📋 Recommendations

  1. Add Tests: Create tests specifically for the new createRivetKit API to ensure it behaves identically to the old pattern
  2. Documentation: Update any documentation that references the old two-step pattern
  3. Migration Guide: Consider adding a migration note for developers using the old API

🏁 Verdict

This is a well-executed refactor that improves the developer experience without breaking existing functionality. The implementation is clean, consistent, and maintains good backward compatibility. The only concern is the lack of new test coverage for the updated API.

Recommendation: ✅ Approve with suggestion to add test coverage in a follow-up.


Copy link
Member Author

NathanFlurry commented Oct 15, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 15, 2025

More templates

@rivetkit/actor

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/actor@1392

@rivetkit/cloudflare-workers

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/cloudflare-workers@1392

@rivetkit/core

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/core@1392

@rivetkit/db

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/db@1392

@rivetkit/framework-base

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/framework-base@1392

@rivetkit/next-js

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/next-js@1392

@rivetkit/react

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/react@1392

rivetkit

pnpm add https://pkg.pr.new/rivet-dev/rivetkit@1392

@rivetkit/sql-loader

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/sql-loader@1392

commit: f24f749

@graphite-app
Copy link

graphite-app bot commented Oct 15, 2025

Merge activity

  • Oct 15, 9:51 AM UTC: NathanFlurry added this pull request to the Graphite merge queue.
  • Oct 15, 9:52 AM UTC: CI is running for this pull request on a draft pull request (#1394) due to your merge queue CI optimization settings.
  • Oct 15, 9:53 AM UTC: Merged by the Graphite merge queue via draft PR: #1394.

@graphite-app graphite-app bot closed this Oct 15, 2025
@graphite-app graphite-app bot deleted the 10-15-chore_core_update_createrivetkit_to_accept_a_client_options branch October 15, 2025 09:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant