Prerequisites
Before you begin, make sure you have:- A React application (v19+ recommended)
- Node.js 18 or higher
- An account on WellPlayed Console
Get Your Credentials
Create an Organization
Sign in to the WellPlayed Console and create an organization if you haven’t already. Note your Organization ID from the dashboard.
Create an Application
Navigate to the Apps section and create a new application. Configure:
- Application Name: Your app’s name
- Redirect URIs: Add
http://localhost:3000/loginfor development - Allowed Origins: Add
http://localhost:3000for CORS
Installation
Install the React SDK
Install the WellPlayed React SDK package:The React SDK automatically includes the TypeScript SDK as a dependency.
Setup the Provider
Wrap Your App with WellPlayedProvider
Import the
WellPlayedProvider and wrap your application. This component handles authentication, Apollo Client setup, and provides the WellPlayed context.src/main.tsx
Understanding the Configuration
The
WellPlayedProvider accepts several props:organizationId(required): Your organization ID from the WellPlayed ConsolewpAppConfig(required): Application configuration object:client_id: Your application’s client IDredirect_uri: Where users return after authentication (must match console config)scope: OAuth scopes - use"offline_access"to enable token refresh
apiBaseUrl(optional): API environment - defaults to"well-played.gg", use"stg.well-played.gg"for stagingclientConfig(optional): Advanced Apollo Client configurationoidcConfig(optional): Additional OIDC provider settings
The
redirect_uri must include a path segment (e.g., /login). Using just the origin will cause an error. This path doesn’t need to exist as a route - the OIDC library handles the callback automatically.Authenticate a User
Now let’s add authentication to your app using theuseConnectedPlayer hook.
Create Your App Component
Use the
useConnectedPlayer hook to access authentication state and user data:src/App.tsx
Fetch Player Data
Let’s extend the example to fetch multiple player profiles using theusePlayers hook.
src/PlayerList.tsx
The
usePlayers hook automatically handles pagination and batching. It fetches up to 100 players per request and combines the results.Access the GraphQL Client
For advanced use cases, you can access the underlying Apollo Client or typed client:src/CustomQuery.tsx
What’s Available in the Context
TheuseWellPlayed hook provides access to:
wp.provider.tsx:86-94
Next Steps
Explore React Hooks
Learn about all available hooks for tournaments, teams, and players
Tournament Guide
Build a complete tournament bracket system
TypeScript SDK
Use the typed client for server-side or non-React applications
API Reference
Browse the complete API documentation
Common Issues
Error: redirect_uri must include a path
Error: redirect_uri must include a path
Make sure your
redirect_uri includes a path segment:Error: useWellPlayed must be used within a WellPlayedProvider
Error: useWellPlayed must be used within a WellPlayedProvider
Ensure your component is rendered inside the
WellPlayedProvider:CORS errors during authentication
CORS errors during authentication
Verify that you’ve added your application’s origin to the Allowed Origins list in the WellPlayed Console app configuration.
Token not refreshing
Token not refreshing
Make sure you include
offline_access in the scope:For more examples and advanced usage patterns, check out the demo application in the SDK repository.