Quick Start
Get up and running with RilayKit in 5 minutes. Perfect for developers who want to jump straight into code.
Quick Start
Get a working form in 5 minutes. This guide skips explanations and focuses on getting you productive fast.
1. Install
pnpm add @rilaykit/core @rilaykit/forms
npm install @rilaykit/core @rilaykit/forms
yarn add @rilaykit/core @rilaykit/forms
2. Create Components
import { ComponentRenderer } from '@rilaykit/core';
interface InputProps {
label: string;
type?: string;
placeholder?: string;
}
export const Input: ComponentRenderer<InputProps> = ({
id, value, onChange, onBlur, error, props
}) => (
<div className="mb-4">
<label htmlFor={id} className="block text-sm font-medium mb-1">
{props.label}
</label>
<input
id={id}
type={props.type || 'text'}
value={value || ''}
onChange={(e) => onChange?.(e.target.value)}
onBlur={onBlur}
placeholder={props.placeholder}
className="w-full p-2 border rounded focus:ring-2 focus:ring-blue-500"
/>
{error && <p className="text-red-500 text-sm mt-1">{error[0].message}</p>}
</div>
);
3. Configure RilayKit
import { ril } from '@rilaykit/core';
import { Input } from '../components/Input';
export const rilay = ril.create()
.addComponent('input', { renderer: Input });
4. Build Form
import { required, email } from '@rilaykit/core';
import { rilay } from '../lib/rilay';
export const loginForm = rilay
.form('login')
.add({
id: 'email',
type: 'input',
props: { label: 'Email', type: 'email' },
validation: [required(), email()]
})
.add({
id: 'password',
type: 'input',
props: { label: 'Password', type: 'password' },
validation: [required()]
});
5. Render Form
import { Form, FormField } from '@rilaykit/forms';
import { loginForm } from '../forms/login';
export function LoginForm() {
const handleSubmit = (data: { email: string; password: string }) => {
console.log('Login:', data);
// Handle login logic
};
return (
<Form formConfig={loginForm} onSubmit={handleSubmit}>
<FormField fieldId="email" />
<FormField fieldId="password" />
<button
type="submit"
className="w-full bg-blue-600 text-white py-2 px-4 rounded hover:bg-blue-700"
>
Sign In
</button>
</Form>
);
}
6. Use Anywhere
import { LoginForm } from '../components/LoginForm';
export default function LoginPage() {
return (
<div className="max-w-md mx-auto mt-8">
<h1 className="text-2xl font-bold mb-6">Sign In</h1>
<LoginForm />
</div>
);
}
✅ Done!
You now have a fully functional, validated login form.
What's Next?
Common Patterns
Multiple Input Types
// Support different input types with one component
export const rilay = ril.create()
.addComponent('input', { renderer: Input })
.addComponent('textarea', {
renderer: Input,
defaultProps: { multiline: true }
})
.addComponent('select', { renderer: SelectInput });
Validation with Zod
import { zodFieldValidator } from '@rilaykit/validation-adapters/zod';
import { z } from 'zod';
const form = rilay.form('user')
.add({
id: 'email',
type: 'input',
validation: [zodFieldValidator(z.string().email())]
});
Conditional Fields
import { when } from '@rilaykit/core';
const form = rilay.form('account')
.add({
id: 'accountType',
type: 'select',
props: { options: [{ value: 'business', label: 'Business' }] }
})
.add({
id: 'companyName',
type: 'input',
conditions: { visible: when('accountType').equals('business') }
});
Custom Validator
import { custom } from '@rilaykit/core';
const passwordMatch = (confirmPassword: string) =>
custom((password: string) => {
if (password !== confirmPassword) {
throw new Error('Passwords do not match');
}
return password;
});
// Usage
.add({
id: 'confirmPassword',
type: 'input',
validation: [required(), passwordMatch(formData.password)]
})
Pro tip: Save the examples above as code snippets in your editor for faster development.
Templates
Clone ready-to-use templates:
npx create-next-app@latest my-app --typescript
cd my-app
pnpm add @rilaykit/core @rilaykit/forms
npm create vite@latest my-app -- --template react-ts
cd my-app
pnpm add @rilaykit/core @rilaykit/forms
npx create-remix@latest my-app --typescript
cd my-app
pnpm add @rilaykit/core @rilaykit/forms
For complete project templates, visit our GitHub templates.
Need Help?
- 📖 Full Tutorial - Step-by-step with explanations
- 🎨 Examples Gallery - Real-world examples
- 📚 API Reference - Complete documentation
- 💬 Discord Community - Get help from the community