Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Redux Toolkit + TypeScript | TypeScript Mastery lesson | BraveProgrammer
  1. Courses
  2. /
  3. TypeScript Mastery

Lesson 31 of 56

·Typescript

Redux Toolkit + TypeScript

25 minutes

Course progress55%

Installing

npm i @reduxjs/toolkit react-redux
npm i -D @types/react-redux

Slice with Types

import { createSlice, PayloadAction } from '@reduxjs/toolkit';

type CounterState = { value:  };

 :  = { :  };

 counterSlice = ({
  : ,
  initialState,
  : {
    () { state.++; },
    () { state. += action.; }
  }
});
  { increment, add } = counterSlice.;
  counterSlice.;
number
const
initialState
CounterState
value
0
const
createSlice
name
'counter'
reducers
increment
state
value
add
state, action: PayloadAction<number>
value
payload
export
const
actions
export
default
reducer

Typed useSelector

import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux';
import { RootState, AppDispatch } from './store';

export const useAppDispatch = () => useDispatch<AppDispatch>();
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;

Info

When using createAsyncThunk, the generated action types are fully typed – you get correct payload typing in reducers.
Make it stickPractice what you've learned1 quiz · 3 practical tests · Optional activities from TypeScript MasteryBrowse activities
Previous lessonReact Context API TypingContinue to lesson 32Angular Basics – TypeScript FoundationsBack to TypeScript Mastery curriculum