Skip to content

Commit 1ae1649

Browse files
authored
Add quick start guide for UltimateAuth setup
Added a quick start guide for setting up UltimateAuth with Blazor Server, including project creation, package installation, service configuration, middleware setup, and first login example.
1 parent bf9598f commit 1ae1649

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# ⚡ Quick Start
2+
3+
In this guide, you will set up UltimateAuth in a few minutes and perform your **first login**.
4+
5+
---
6+
7+
## 1. Create a Project
8+
9+
Create a new Blazor Server web app:
10+
11+
```bash
12+
dotnet new blazorserver -n UltimateAuthDemo
13+
cd UltimateAuthDemo
14+
```
15+
16+
## 2. Install Packages
17+
18+
Add UltimateAuth packages:
19+
20+
```csharp
21+
dotnet add package CodeBeam.UltimateAuth.Server
22+
dotnet add package CodeBeam.UltimateAuth.Client.Blazor
23+
dotnet add package CodeBeam.UltimateAuth.InMemory.Bundle
24+
```
25+
26+
## 3. Configure Services
27+
28+
Update your Program.cs:
29+
```csharp
30+
builder.Services
31+
.AddUltimateAuthServer()
32+
.AddUltimateAuthInMemory();
33+
34+
builder.Services
35+
.AddUltimateAuthClientBlazor();
36+
```
37+
38+
## 4. Configure Middleware
39+
In `Program.cs`
40+
```csharp
41+
app.UseUltimateAuthWithAspNetCore();
42+
app.MapUltimateAuthEndpoints();
43+
```
44+
45+
## 5. Enable Blazor Integration
46+
In `Program.cs`
47+
```csharp
48+
app.MapRazorComponents<App>()
49+
.AddInteractiveServerRenderMode() // or webassembly (depends on your application type)
50+
.AddUltimateAuthRoutes(UAuthAssemblies.BlazorClient());
51+
```
52+
53+
## 6. Add UAuth Script
54+
Add this to `App.razor` or `index.html`:
55+
56+
```csharp
57+
<script src="_content/CodeBeam.UltimateAuth.Client.Blazor/uauth.min.js"></script>
58+
```
59+
60+
## 7. Configure Application Lifecycle
61+
Replace `Routes.razor` with this code:
62+
```csharp
63+
<UAuthApp UseBuiltInRouter="true" AppAssembly="typeof(Program).Assembly" DefaultLayout="typeof(Layout.MainLayout)" />
64+
```
65+
66+
## 8. Perform Your First Login
67+
Example using IUAuthClient:
68+
```csharp
69+
[Inject] IUAuthClient UAuthClient { get; set; } = null!;
70+
71+
private async Task Login()
72+
{
73+
await UAuthClient.Flows.LoginAsync(new LoginRequest
74+
{
75+
Identifier = "demo",
76+
Secret = "password"
77+
});
78+
}
79+
```
80+
81+
## 🎉 That’s It
82+
You now have a working authentication system with:
83+
84+
- Session-based authentication
85+
- Automatic client detection
86+
- Built-in login flow
87+
- Secure session handling
88+
89+
## What Just Happened?
90+
91+
When you logged in:
92+
93+
- A session (with root and chain) was created on the server,
94+
- Your client received an authentication grant (cookie or token),
95+
- UltimateAuth established your auth state automatically.
96+
97+
👉 You didn’t manage cookies, tokens, or redirects manually.
98+
99+
## Next Steps
100+
Discover the setup for real world applications with entity framework core.

0 commit comments

Comments
 (0)