A very simple solution is using the sfcookies package. You just have to install it using npm for example: npm install sfcookies --save
Then you import on the file:
import { bake_cookie, read_cookie, delete_cookie } from 'sfcookies';
create a cookie key:
const cookie_key = 'namedOFCookie';
on your submit function, you create the cookie by saving data on it just like this:
bake_cookie(cookie_key, 'test');
to delete it just do
delete_cookie(cookie_key);
and to read it:
read_cookie(cookie_key)
Simple and easy to use.