> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devdeia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Database Storage

> Persist UI preferences per user, across sessions and devices.

By default, preferences are stored in the session — they reset on logout. To persist them per user instead:

<Steps>
  <Step title="Publish and run the migration">
    ```bash theme={null}
    php artisan vendor:publish --tag=filament-ui-switcher-migrations
    php artisan migrate
    ```

    This adds a `ui_preferences` JSON column to your `users` table.
  </Step>

  <Step title="Add the HasUiPreferences trait to your User model">
    ```php theme={null}
    use Andreia\FilamentUiSwitcher\Models\Traits\HasUiPreferences;

    class User extends Authenticatable
    {
        use HasUiPreferences;

        protected function casts(): array
        {
            return [
                // ...
                'ui_preferences' => 'array',
            ];
        }
    }
    ```
  </Step>

  <Step title="Switch the driver to database">
    ```php config/ui-switcher.php theme={null}
    'driver' => 'database',
    ```

    Preferences now save per-user and persist across logins.
  </Step>
</Steps>
