Skip to content

feat: allow custom storage strategies via lifecycle hooks and custom readers#1528

Open
EmaSchiavoni wants to merge 5 commits intoThinkmill:mainfrom
EmaSchiavoni:feat/lifecycle-hooks-and-custom-reader
Open

feat: allow custom storage strategies via lifecycle hooks and custom readers#1528
EmaSchiavoni wants to merge 5 commits intoThinkmill:mainfrom
EmaSchiavoni:feat/lifecycle-hooks-and-custom-reader

Conversation

@EmaSchiavoni
Copy link
Copy Markdown

While Keystatic's internal persistence (local/GitHub) is excellent for most use cases, there are times when a project requires a specific collection to be managed externally due to custom business logic. Instead of forcing developers to leave the Keystatic ecosystem for these exceptions, this pull request introduces two complementary features that, together, allow for seamless integration into the same unified workflow:

  1. Lifecycle Hooks (beforeSave, beforeDelete): New callbacks for collections and singletons. They provide full control over the persistence flow by receiving a save/delete function as an argument. This allows for side effects (logging, external sync) or complete overrides of the default behavior.
  2. Custom Readers: A new reader property in the config that allows developers to define how data is fetched.

I know these could be two separate features, but I'm intentionally submitting them in a single PR because together they form a coherent extensibility tool: The hooks allow a "true" return value to indicate a successful operation even if Keystatic's internal save function wasn't called (for example, when saving to an external API). Without the custom reader, this would result in an inconsistent UI state where data is saved externally, but Keystatic can't retrieve it

…leton configs to enable callback hooks.

These callback hooks allow devs to perform actions on saving or deleting, even letting you decide whether to proceed with saving or deleting, respectively, through the function call received as an argument.
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 5, 2026

⚠️ No Changeset found

Latest commit: ac53445

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant