Run the React login starter
Run the downloadable React starter to log in with RemiliaNET, show the connected profile, and log out.
The starter uses the oidc-spa library and the official login button. It suits a
first working login in a React web app.
Prerequisites
- Bun and a browser.
- An approved Login client with the callback
http://localhost:5173/, registered exactly. For the steps, see Register an application.
The development server of the starter keeps port 5173 fixed.
Steps
- Download the runnable React starter.
- Unzip the archive.
- Run
bun installin the starter folder. - Copy
.env.exampleto.env.local. - Set
VITE_REMILIA_CLIENT_IDin.env.localto your public client ID. - Run
bun run dev. - Open
http://localhost:5173/. - Select Log in with RemiliaNET.
- Complete login and consent at RemiliaNET.
- Select Log out.
- Log in again with another account.
Result
After login, the starter shows the display name and the handle of the connected
user. Its /api/v1/me request returns 200. The profile is a root object, not
a data envelope.
After logout, the account disappears. Late login and profile responses from the earlier session do not restore it. After you log in with another account, the displayed profile changes.
When the profile request fails, the starter shows the error and a retry control. It does not show tokens. For more information about missing scopes, see App permissions.
Troubleshooting
If login, the callback, or the profile request fails, match the error to its cause in Login and API requests fail.
Starter source
The starter configures oidc-spa in a Vite React app. Each file holds one part
of the integration:
To reuse this configuration in another Vite app, keep these facts:
- The callback of a Vite app is its base URL with the trailing slash, such as
https://yourapp.example/. For local development, register an exact loopback URL or an HTTPS development hostname, verbatim. getAccessToken()renews the access token when needed.- A backend validates an ID token before it uses the claims to identify the user. It does not trust identity claims that a browser sends without validation.
For other frameworks, see the oidc-spa documentation.
Next steps
- For the response fields, see Get your own profile.
- For feature permissions, see Check permissions before you enable a feature.
- For logout behavior, see Log a user out of your app.
- For the other button styles, labels, and files, see the login button kit.
