Skip to content
Source
Sign inSign up
TanStack/form
Open History to see the last commit

utils.ts

23 lines581 Bytes

1import {
2 deleteCookie,
3 getCookie,
4 setCookie,
5} from '@tanstack/react-start/server'
6import { parse, stringify } from 'devalue'
7​
8const _INTERNALS_COOKIE_NAME = '_tanstack_form_internals'
9​
10export const setInternalTanStackCookie = (data: any) => {
11 const cookie = stringify(data)
12 setCookie(_INTERNALS_COOKIE_NAME, cookie)
14​
15export const getInternalTanStackCookie = () => {
16 const cookie = getCookie(_INTERNALS_COOKIE_NAME)
17 if (!cookie) return undefined
18 return parse(cookie)
20​
21export const deleteInternalTanStackCookie = () => {
22 deleteCookie(_INTERNALS_COOKIE_NAME)