Skip to main content

Introduction

The Storage API provides a comprehensive set of functions for managing all persistent data in the Rippler workout tracker. Built on top of React Native’s AsyncStorage, it handles exercises, logged workouts, target overrides, goal weights, and program progression.

Architecture

All storage operations are asynchronous and handle errors gracefully, returning default values when data retrieval fails. The API uses a centralized key management system to ensure consistent data access across the application.

Storage Keys

The following AsyncStorage keys are used throughout the application:
@rippler/exercises
string
Stores the array of user exercises with their IDs, names, and optional notes
@rippler/logged_workouts
string
Contains all completed workout sessions with exercise logs and timestamps
@rippler/current_week
string
Tracks the user’s current week in the Rippler program (1-16)
@rippler/target_overrides
string
Stores custom weight/rep/set targets that override program defaults
@rippler/goal_weights
string
Maps exercise names to user-defined goal weights

Data Flow

Core Functionality

The Storage API is organized into five main categories:

Exercise Management

Create, read, update, and delete exercises from your workout library. Each exercise has a unique ID, name, and optional notes. Learn more →

Workout Logging

Persist completed workouts with detailed set-by-set tracking, including weights, reps, and completion status for each exercise. Learn more →

Goal Setting

Define and track target weights for each exercise to measure progress throughout the program. Learn more →

Target Overrides

Customize specific workout targets for any day in the program, allowing flexibility while maintaining structure. Learn more →

Error Handling

All storage functions implement try-catch error handling:
try {
  const data = await AsyncStorage.getItem(key);
  return data ? JSON.parse(data) : defaultValue;
} catch (error) {
  console.error('Error message:', error);
  return defaultValue;
}
All storage operations fail silently and return safe defaults. Monitor console logs during development to catch storage issues.

Data Types

The Storage API works with these core TypeScript types:
export interface Exercise {
  id: string;
  name: string;
  notes?: string;
}

Best Practices

Storage functions are asynchronous. Always use await or .then() to ensure data is persisted before proceeding.
// Good
await saveExercises(exercises);
console.log('Saved!');

// Bad - save might not complete
saveExercises(exercises);
console.log('Saved!');
Getter functions like getExercises() automatically initialize data with sensible defaults if nothing exists.
// Automatically gets defaults if no exercises exist
const exercises = await getExercises();
For multiple changes, modify the array in memory and save once rather than saving after each change.
// Good - single save
const exercises = await getExercises();
exercises.push(newExercise1);
exercises.push(newExercise2);
await saveExercises(exercises);

// Bad - multiple saves
await addExercise('Exercise 1');
await addExercise('Exercise 2');

Import

import {
  getExercises,
  saveLoggedWorkout,
  setGoalWeight,
  saveTargetOverride,
  getCurrentWeek
} from '@/lib/storage';

Next Steps

Exercise Storage

Manage your exercise library

Workout Storage

Log and retrieve workout sessions

Goal Storage

Set and track goal weights

Override Storage

Customize workout targets

Build docs developers (and LLMs) love