PHPackages                             peping/nette-pagestate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. peping/nette-pagestate

ActiveLibrary

peping/nette-pagestate
======================

040PHP

Since Aug 4Pushed 9y ago1 watchersCompare

[ Source](https://github.com/Peping/nette-pagestate)[ Packagist](https://packagist.org/packages/peping/nette-pagestate)[ RSS](/packages/peping-nette-pagestate/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

nette-pagestate
===============

[](#nette-pagestate)

Nette Pagestate is a library that helps keep a [nette](http://github.com/nette/nette) application state between subrequests (signals) by storing the state in the browser's DOM and submitting it to the server each time a subrequest is made via AJAX (using [nette.ajax.js](https://github.com/vojtech-dobes/nette.ajax.js). It is especially useful in situations when you need to create more complex and interactive nette components using javascript, but your project's UI and most operations still need to be done on the server.

**BE SURE TO ALSO INSTALL THE CLIENT SIDE:** [peping/nette.pagestate.js](https://github.com/Peping/nette.pagestate.js)

Installation
------------

[](#installation)

Use Composer to install the server-side package:

```
composer install peping/nette-pagestate

```

Usage
-----

[](#usage)

Ensure that your application loads composer packages correctly (i. e. includes `autoload.php`). If you want to use pagestate inside a component (instead of just a presenter), make sure that it has [autowiring](https://pla.nette.org/cs/inject-autowire) enabled.

At the start of the class, use the `TPageState` trait. This allows you to set the page state.

```
class HomePresenter extends Presenter
{
use TPageState;
...
}
```

Every component in your application has its own page state designated by its `uniqueId`. You can set and get values like this:

```
public function render()
{
	$pagestate = $this->getPageState();

	// Get the number of times the button has been clicked in the browser's currently loaded page

	// PHP 7
	$clickCount = $pageState->clickCount ?? 0;

	// PHP 5
	$clickCount = isset($pageState->clickCount) ? $pageState->clickCount : 0;

	// Pass the clickCount to the template
	$this->template->clickCount = $clickCount;
}

public function handleClick()
{
	// The button has been clicked, increment the click count and redraw the button's snippet

	// PHP 7
	$pageState->clickCount = ($pageState->clickCount ?? 0) + 1;

	// PHP 5
	$pageState->clickCount = isset($pageState->clickCount) ? $pageState->clickCount + 1 : 1;

	// redraw the button's snippet.
	$this->redrawControl('buttonSnippet');
}
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/d7d31a1a13cefbfa1b6cffca7be31345f0771409e0764ad7ce4d8aba0f23f370?d=identicon)[Peping](/maintainers/Peping)

### Embed Badge

![Health badge](/badges/peping-nette-pagestate/health.svg)

```
[![Health](https://phpackages.com/badges/peping-nette-pagestate/health.svg)](https://phpackages.com/packages/peping-nette-pagestate)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
