A modern, responsive admin portal built with SvelteKit, TypeScript, and Tailwind CSS. This project provides a comprehensive foundation for building admin interfaces with user management, notifications, authentication, and more.
Clone the repository
git clone <repository-url>
cd learn-svelte
Install dependencies
npm install
Start the development server
npm run dev
Open your browser
Navigate to http://localhost:5173
For testing purposes, use these credentials:
[email protected]
password
src/
āāā lib/
ā āāā components/
ā ā āāā ui/ # Reusable UI components
ā ā āāā Button.svelte
ā ā āāā Input.svelte
ā ā āāā Select.svelte
ā ā āāā Modal.svelte
ā ā āāā Toast.svelte
ā āāā stores/ # Svelte stores for state management
ā ā āāā auth.ts # Authentication state
ā ā āāā users.ts # User management state
ā ā āāā notifications.ts # Notifications state
ā ā āāā toast.ts # Toast notifications
ā ā āāā theme.ts # Theme management
ā āāā utils.ts # Utility functions
ā āāā validation.ts # Zod validation schemas
āāā routes/
ā āāā +layout.svelte # Main layout with navigation
ā āāā +page.svelte # Root page (redirects)
ā āāā login/
ā ā āāā +page.svelte # Login page
ā āāā dashboard/
ā ā āāā +page.svelte # Dashboard with overview
ā āāā users/
ā ā āāā +page.svelte # User management page
ā āāā notifications/
ā āāā +page.svelte # Notifications page
āāā app.css # Global styles with Tailwind
<Button variant="primary" size="md" loading={false}>
Click me
</Button>
Variants: primary
, secondary
, outline
, ghost
, destructive
Sizes: sm
, md
, lg
<Input
label="Email"
type="email"
bind:value={email}
error={errors.email}
placeholder="Enter your email"
required
/>
<Select
label="Role"
bind:value={role}
options={roleOptions}
error={errors.role}
required
/>
<Modal bind:open={showModal} title="Edit User" size="md">
<p>Modal content goes here</p>
<div slot="footer">
<Button variant="outline" on:click={() => showModal = false}>
Cancel
</Button>
<Button on:click={handleSave}>
Save
</Button>
</div>
</Modal>
The application uses Svelte stores for state management:
import { authStore, login, logout } from '$lib/stores/auth';
// Login
const result = await login(email, password);
// Logout
logout();
// Access current user
$authStore.user
import {
usersStore,
loadUsers,
createUser,
updateUser,
deleteUser,
setFilter,
setPagination
} from '$lib/stores/users';
// Load users
await loadUsers();
// Create user
await createUser(userData);
// Filter users
setFilter({ search: 'john', role: 'admin' });
// Pagination
setPagination({ page: 2 });
import { showSuccess, showError, showWarning, showInfo } from '$lib/stores/toast';
showSuccess('Success!', 'Operation completed successfully');
showError('Error!', 'Something went wrong');
# Development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview
# Run tests
npm run test
# Run linting
npm run lint
# Format code
npm run format
Create Store (if needed)
// src/lib/stores/feature.ts
import { writable } from 'svelte/store';
export const featureStore = writable(initialState);
Add Validation Schema
// src/lib/validation.ts
export const featureSchema = z.object({
// Define schema
});
Create Components
<!-- src/lib/components/Feature.svelte -->
<script lang="ts">
// Component logic
</script>
<!-- Component template -->
Add Routes
<!-- src/routes/feature/+page.svelte -->
<script lang="ts">
// Page logic
</script>
<!-- Page template -->
npm run build
Create a .env
file for environment-specific configuration:
# API Configuration
PUBLIC_API_URL=https://api.example.com
PRIVATE_API_KEY=your-secret-key
# Database Configuration
DATABASE_URL=your-database-url
This SvelteKit application can be deployed to various platforms:
This project is licensed under the MIT License - see the LICENSE file for details.
git checkout -b feature/amazing-feature
)git commit -m 'Add some amazing feature'
)git push origin feature/amazing-feature
)If you have any questions or need help with the project, please:
Happy coding! š